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 :
Service | Customer Service, Contact Center, Fie...
Answered

Dynamics API is broken

(0) ShareShare
ReportReport
Posted on by

Hello, Our system is an Java application which integrates with Dynamics CRM, in the last few years we haven`t made any change, from last week, the following API is broken. I have two issues.
First issue, since we haven`t made any change, but the API is broken, I believe Dynamics must have made some change on their end.

String url = "https://{client name}.crm.dynamics.com/api/data/v9.1.0.6228/z2t_models?fetchXml=";
restTemplate.exchange(url, HttpMethod.GET, entity, String.class);

The API returns 500 internal error, the error message of response:

{"error":{"code":"0x0","message":"Unexpected character encountered while parsing value: \ufffd. Path '', line 0, position 0."}}

But I can call this API successfully using postman, it isn`t helpful from the error message. I am wondering what change I should make in order to call this API successfully.

Second issue, I made some change, removed the parameters from original url, and sent the parameters in the exchange method, for example,

String url = "https://{client name}.crm.dynamics.com/api/data/v9.1.0.6228/z2t_models";
String param = "";
Map params = new HashMap<>();
params.put("fetchXml", param);
restTemplate.exchange(url, HttpMethod.GET, entity, String.class, params);

It returns 200, but it returns a lot more information in response body which will causes out of memory issue on our end.

I will appreciate any help here, thanks!

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Ning Morris,

    Please try the below url:

    String url = "https://{client name}.crm.dynamics.com/api/data/v9.1/z2t_models?$select=z2t_modelid,z2t_machinekind,z2t_name"

  • Suggested answer
    Bipin D365 Profile Picture
    28,995 Moderator on at

    Hi,

    One thing which I have noticed is Api version number. I would highly recommend to update it with the value which is highlighted below as per your instance-

    CR15.PNG

    Second - You should use encoreuricomponent to encode the fetchxml before sending it to dynamics crm platform. see below link for more details-

    https://www.inogic.com/blog/2019/04/handling-special-characters-while-executing-fetch-xml-programmatically-in-web-api-rest-call/

    Would you be able to share us the response which you are getting ?

    Ideally it should only return the fields value which is defined in fetchxml attribute tag. What additional details are getting returned from the Dynamics crm platform?

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Community Member Profile Picture
    on at

    Steven Zhao, thank you!

    The url you shared works, but this url only returns first page which contains 5000 models, I believe there are more than one page, I am wondering

    1. what is the URL to send page number?

    Something like https://{client name}.crm.dynamics.com/api/data/v9.1/z2t_models?$select=z2t_modelid,z2t_machinekind,z2t_name&page=2

    2. What is the URL to get total pages?

    Something like https://{client name}.crm.dynamics.com/api/data/v9.1/z2t_models/totalPage

  • Community Member Profile Picture
    on at

    Bipin Kumar, thank you!

    I tried your suggestions, updated version to 9.2, also encoded the URL parameters, unfortunately I still got the same 500 internal error.

    I expect to get models which only contains three fields, but I got a response as follows.

    {
    
     "@odata.context": "https://{client name}.com/api/data/v9.2/$metadata#z2t_models",
    
     "value": [
    
       {
    
         "@odata.etag": "W/\"15602996771\"",
    
         "z2t_name": "GLP050RGNUAE090",
    
         "z2t_recid": "5637154544",
    
         "_owningbusinessunit_value": "36b9b50c-8f62-e711-80ff-c4346bdcf131",
    
         "z2t_machinekind": "FORKLIFT",
    
         "statecode": 0,
    
         "statuscode": 1,
    
         "_createdby_value": "a2744195-0e7d-e711-8105-c4346bdc92b1",
    
         "z2t_machinemanufacturer": "YALE",
    
         "z2t_isattachment": false,
    
         "_ownerid_value": "a2744195-0e7d-e711-8105-c4346bdc92b1",
    
         "modifiedon": "2021-09-17T19:33:14Z",
    
         "_owninguser_value": "a2744195-0e7d-e711-8105-c4346bdc92b1",
    
         "_modifiedby_value": "a2744195-0e7d-e711-8105-c4346bdc92b1",
    
         "z2t_modelid": "ec5783b4-3150-4732-8a00-00025beed633",
    
         "versionnumber": 15602996771,
    
         "createdon": "2017-10-03T08:05:55Z",
    
         "z2t_description": "FORKLIFT",
    
         "utcconversiontimezonecode": null,
    
         "timezoneruleversionnumber": null,
    
         "_owningteam_value": null,
    
         "_modifiedonbehalfby_value": null,
    
         "importsequencenumber": null,
    
         "_createdonbehalfby_value": null,
    
         "overriddencreatedon": null
    
       },
    
       {
    
         "@odata.etag": "W/\"15602992232\"",
    
         "z2t_name": "GDP210DBECDE131",
    
         "z2t_recid": "5637149197",
    
         "_owningbusinessunit_value": "36b9b50c-8f62-e711-80ff-c4346bdcf131",
    
         "z2t_machinekind": "FORKLIFT",
    
         "statecode": 0,
    
         "statuscode": 1,
    
         "_createdby_value": "a2744195-0e7d-e711-8105-c4346bdc92b1",
    
         "z2t_machinemanufacturer": "YALE",
    
         "z2t_isattachment": false,
    
         "_ownerid_value": "a2744195-0e7d-e711-8105-c4346bdc92b1",
    
         "modifiedon": "2021-09-17T19:30:01Z",
    
         "_owninguser_value": "a2744195-0e7d-e711-8105-c4346bdc92b1",
    
         "_modifiedby_value": "a2744195-0e7d-e711-8105-c4346bdc92b1",
    
         "z2t_modelid": "c596068e-0d8b-49b9-9e99-00035a9fc66f",
    
         "versionnumber": 15602992232,
    
         "createdon": "2017-10-02T17:57:24Z",
    
         "z2t_description": "FORKLIFT",
    
         "utcconversiontimezonecode": null,
    
         "timezoneruleversionnumber": null,
    
         "_owningteam_value": null,
    
         "_modifiedonbehalfby_value": null,
    
         "importsequencenumber": null,
    
         "_createdonbehalfby_value": null,
    
         "overriddencreatedon": null
    
       },
    
       .....
    
    ]

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Ning Morris,

    what is the URL to send page number?

    Please refer to this blog: https://vjcity.blogspot.com/2020/06/how-to-get-specific-page-number-in.html

    What is the URL to get total pages?

    There is no way to get total pages.  When you set page size at request header, it would return next page link. However, you could add $count=true to your URL such as https://{client name}.crm.dynamics.com/api/data/v9.1/z2t_models?$count=true. It would return total count of your entity records and you could use it to calculate your total pages.

  • Community Member Profile Picture
    on at

    Hi Steve Zhao

    It worked, thank you so much!

  • Community Member Profile Picture
    on at

    Hi Ning Morris,

    If you think my answer help you, you could verify my answer:

    pastedimage1639721831739v2.png

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Travis South Profile Picture

Travis South 54

#2
11manish Profile Picture

11manish 37 Super User 2026 Season 2

#3
ParthPatel249 Profile Picture

ParthPatel249 33

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans