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)

Web API: default format gives empty response, but minor formatting errors give correct response.

(1) ShareShare
ReportReport
Posted on by

I am having a very strange issue with the web api when making http 'GET' calls to retrieve dynamics Account Entities.  I am attempting to make JavaScript XMLHttp Requests from an html web resource inside dynamics. 

As per the Documentation, I am making api calls to retrieve an Account with this uri: 

GET [Organization URI]/api/data/v8.2/accounts(00000000-0000-0000-0000-000000000001)

This works for some accounts, but for other accounts i receive an empty response " {} " from other accounts.
However, the strange thing is I will get a correct response from some of the failed accounts when I slightly
alter the format of the api call. There are 3 things that I have noticed that I can do that will cause these calls
to return data:
1) change the api version

Example: 
[Organization URI]/api/data/v8.2/accounts(49DAAE84-C747-E711-810D-FC15B4286C00)
will return "{}"

when [Organization URI]/api/data/v8.1/accounts(49DAAE84-c747-E711-810D-FC15B4286C00)
returns the correct acocunt data.

2) Add a space in between the parenthesis and the account GUID

Example:
[Organization URI]/api/data/v8.2/accounts(49DAAE84-C747-E711-810D-FC15B4286C00) returns "{}"
But
[Organization URI]/api/data/v8.2/accounts(49DAAE84-C747-E711-810D-FC15B4286C00%20) returns the correct account data


3) Make one (or more) letter(s) of the GUID lower case

Example:
change
/api/data/v8.2/accounts(49DAAE84-C747-E711-810D-FC15B4286C00)  
to
/api/data/v8.2/accounts(49DAAE84-c747-e711-810D-FC15B4286C00) 


This is a very strange problem, and at this point I would be fine with it if the error was at least consistent, but I can't find any way of encoding the uri so that it will always return
the account information. Has anyone ran into this problem before? Any insight is much appreciated.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    Which version of CRM are you using?

    Also, please go to Settings --> Customisations --> Developer Resources.

    Replace the WebApi URL with the Service Root URL under the Instance Web API.

    25643.1.PNG


    In this case, it will be as follows.

    ServiceRootURL/accounts(475B158C-541C-E511-80D3-3863BB347BA8)

    Hope this helps.

  • Suggested answer
    ram r Profile Picture
    on at

    If v8.1/v8.0 seems consistent, I would prefer to use them over 8.2 for the particular scenario.

  • Community Member Profile Picture
    on at

    Neither are consistent.  I can make a call from account A using 8.2 and it will return valid json, but will return {} with 8.1/8.0.

    Then I make a call from account B using 8.2 and it retuns {} , but will return valid json with 8.0.

    Then from account C Neither of them work.

    I do not think this is simply a problem with the api version, because changing one letter from upper to lower case can also make the difference between and empty response and a valid response.

  • ram r Profile Picture
    on at

    Just a thought, try the guid with all alphabets in lower case. Most the ms samples are in lowecase! If that work go with it.

  • Community Member Profile Picture
    on at

    I am using Dynamics 365 Online.

    Also, I am using the service root url, unless you are suggesting getting the service root url as a variable and using that, which I do not believe would make any difference tothe http call.

    Also, I am using a sandbox if that helps.

  • Community Member Profile Picture
    on at

    I already tried that and the same problem persists. Any other suggestions?

  • Suggested answer
    ram r Profile Picture
    on at

    If possible can you use filters to retrieve record. Something like below

    /api/data/v8.2/accounts?$filter=accountid%20eq%203adbf27c-8efb-e511-80d2-00155db07c77

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