Hi Team,
Have installed custom solution which will create a custom entity "XXX" in the CRM 365 online-- solution installed successfully.
Have tried to access the custom entity in third party application using WebApi method. but getting below error. "
The remote server returned an error: (403) Forbidden. at System.Net.HttpWebRequest.GetResponse()"
Able to access standard entities but unable to access custom entities
Able to fetch desired response with "api/data/v9.0/WhoAmI" , but below URL is throwing exception "api/data/v9.0/XXX".
code Sample:
string token = string.Empty;
string InboundData = "https://crmOrg.api.crm8.dynamics.com/api/data/v9.0/XXX";
try
{
AuthenticationContext authContext =
new AuthenticationContext(Authority);
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ClientCredential credentials = new ClientCredential(ClientId, ClientSecret);
AuthenticationResult _authResult = await authContext.AcquireTokenAsync(Resource, credentials);
token = _authResult.AccessToken;
WebRequest request1 = WebRequest.Create(InboundData);
request1.ContentType = @"application/json; charset=utf-8";
request1.Method = "GET";
request1.Headers.Add("Authorization", "Bearer " + token);
HttpWebResponse response1 = request1.GetResponse() as HttpWebResponse;
string jsonResponse1 = string.Empty;
using (StreamReader sr = new StreamReader(response1.GetResponseStream()))
{
jsonResponse1 = sr.ReadToEnd();
}
}
Thanks.
*This post is locked for comments
Are their routers or firewalls installed in between? Could be locked down so that you cannot access from outside the network?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156