web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Accessing Web API from Azure Web App

(0) ShareShare
ReportReport
Posted on by 100

I created a Web-App (C#) which accesses CRM (Version 1612, 9.0.0.3172, online) using the API (Vers. 9), and a very basic console app to test some ways of handling it; HttpClient (System.Net.Http), OrganizationWebProxyClient (Microsoft.Xrm.Sdk.WebServiceClient) & OrganizationServiceProxy(Microsoft.Xrm.Sdk.Client).

Everything worked fine before Christmas, however, nothing worked when it got back last week.

All methods threw the following exception (Fiddler):
HTTPS handshake to <instance>.api.crm4.dynamics.com (for #<No.>) failed. System.IO.IOException..

I found an article about TLS 1.0 and 1.1 being blocked, so I changed the target framework from 4.6.1 to 4.7.1,  httpRuntime targetFramework from 4.6.1 to 4.7, updated everything in NuGet and added ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12.


OrganizationServiceProxy seems to work now.

OrganizationWebProxyClient throws the following exception:
POST request requires Content-Type application/json”.
The request header contains ‘Content-Type: text/xml; charset=utf-8’.

HttpClient gives me:
HTTP Error 401 - Unauthorized: Access is denied
This call works if I add Bearer to the header. However, I didn’t even specify a Bearer before Christmas (I’m guessing that I should have).
I also noticed that I’m getting “HTTP Error 401 - Unauthorized: Access is denied” instead of being redirected to the login-page when I try to access the CRM API directly from my browsers without first going to CRM.


I’ve tried to create everything from scratch incl. AAD setup, but nothing seems to work.


Am I using the wrong assemblies (OrganizationWebProxyClient)? 

Should I even be able to use HttpClient, without directly specifying Bearer, to access the Web API? Even when it’s used in a Web App registered in AAD, and having permissions for Dynamics CRM Online?


Hoping that someone might point me in the right direction.

*This post is locked for comments

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans