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

Announcements

No record found.

News and Announcements icon
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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans