Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Weird Behavior of CRM Web Api

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

We are using Dynamics CRM Online and it's Web Api for our integration with other systems, we have hit a really weird issue recently, where two Get requests to Web Api, issued at exactly the same time with same Authorization token are returning different results, we are querying guid of a record, one comes back with the Guid the other with Null, there's no chance of that data not being there at that point as that record has been in CRM for a long time and as I said above, these two requests were issued at exactly the same time (as its evident from the time mentioned in response --> see below), I am copying the requests and responses below, if anyone has encountered this issue or can shed some light on why it may be happening, please let us know. B/w we suspect this has been happening before as well as we encountered similar issues before but this was the first time we troubleshooted this in detail with fiddler traces.

Request 1

GET https://<hostname>/api/data/v8.2/contracttemplates?$select=contracttemplateid&$top=10&$filter=name%20eq%20'Service'HTTP/1.1

Accept: application/json

Authorization: Bearer <tokenGoesHere>

Host: <hostname>

Response 1

HTTP/1.1 200 OK

Cache-Control: no-cache

Pragma: no-cache

Content-Type: application/json; odata.metadata=minimal

Expires: -1

Server: Microsoft-IIS/8.5

REQ_ID: 17ff4029-4922-43c9-9550-669b2bf55d49

OData-Version: 4.0

X-AspNet-Version: 4.0.30319

X-Powered-By: ASP.NET

Date: Fri, 18 Aug 2017 12:39:53 GMT

Content-Length: 256

Set-Cookie: crmf5cookie=!Il7rpp79nubHq6bO/8BTxBu52Tf9Z2OGhiSdK4172h26w4CnoBKOlpVhzTS3WE1zO5ewUMcYwts09Ko=;secure; path=/

Strict-Transport-Security: max-age=31536000; includeSubDomains

 

{

  "@odata.context":"https://<hostname>/api/data/v8.2/$metadata#contracttemplates(contracttemplateid)","value":[

    {

      "@odata.etag":"W/\"2030269\"","contracttemplateid":"77ecdfda-3e70-429d-b174-1352b981c5f2"

    }

  ]

}

 Request 2 

GET https://<hostname>/api/data/v8.2/contracttemplates?$select=contracttemplateid&$top=10&$filter=name%20eq%20'Service'HTTP/1.1

Accept: application/json

Authorization: Bearer <tokenGoesHere> 

Host: <hostname>

 

 Response 2

HTTP/1.1 200 OK

Cache-Control: no-cache

Pragma: no-cache

Content-Type: application/json; odata.metadata=minimal

Expires: -1

Server: Microsoft-IIS/8.5

REQ_ID: 01ce4889-a8a7-4f79-8df6-aea00bac7817

OData-Version: 4.0

X-AspNet-Version: 4.0.30319

X-Powered-By: ASP.NET

Date: Fri, 18 Aug 2017 12:39:53 GMT

Content-Length: 222

Set-Cookie: crmf5cookie=!CvztgNYGAJKjhWrO/8BTxBu52Tf9ZzDalf4hpDFQL6yDBDo8jqFdXYjj1Z1EGKDBXw6WSh7OMMT8E34=;secure; path=/

Strict-Transport-Security: max-age=31536000; includeSubDomains

 

{

  "@odata.context":"https://<hostname>/api/data/v8.2/$metadata#contracttemplates(contracttemplateid)","value":[

    {

      "@odata.etag":"W/\"2030269\"","contracttemplateid":null

    }

  ]

}

 

*This post is locked for comments

  • Suggested answer
    Goutham A Profile Picture
    Goutham A on at
    RE: Weird Behavior of CRM Web Api

    Hi Syed,

    I mean while making request to webapi, you need to include this request header

    var xhttp = new XMLHttpRequest();

    /***I intend to mention about below step****/

    xhttp .setRequestHeader("Cache-Control", "max-age=1")  //max-age is in seconds

    xhttp.onreadystatechange = function() {

       if (this.readyState == 4 && this.status == 200) {

    };

    xhttp.open("GET", "filename", true);

    xhttp.send();

    This is a temporary solution.

    I recommend to raise a ticket with microsoft product support team. For me, this appears to be product bug.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Weird Behavior of CRM Web Api

    Thanks Goutham for your suggestion. But I don't totally get that, how would making Cache-Control: public would ensure that second call also returns the right result?

  • Suggested answer
    Goutham A Profile Picture
    Goutham A on at
    RE: Weird Behavior of CRM Web Api

    This is really wierd. This seems to be an issue with CRM product. can you please raise Microsoft ticket for help

    Mean while, you can add cache control header in your request for correct results in second request as well

    Cache-Control: public, max-age=1

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Weird Behavior of CRM Web Api

    Really appreciate if someone can share possible cause for this.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,375 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans