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)

SDK.Rest.updaterecord method throwing an internal server error.

(0) ShareShare
ReportReport
Posted on by 6

Hello All Experts,

I need to know what could be causing the above error to raise.

This issue is non reproducible on dev, test, preprod instances, but it's on production instance.

SDK.REST._errorHandler(this)  // this object having different messages.

responseText: "{ ↵"error": { ↵"code": "-2147220891", "message": { ↵"lang": "en-US", "value": "The application terminated with an error.\nObject reference not set to an instance of an object." ↵} ↵} ↵}"

status: 500

statusText: "Internal Server Error"

how can i resolve this.

any help will be appreciable.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    Object reference not set to an instance of an object. This error occur when one of your field doesn't have value. you have to debug it.

  • EmployeeOcta Profile Picture
    6 on at

    Hello Wei,

    I have checked the same code working fine in the dev instance having the same values, but on production system it's not working.

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    how about the Guid of that value, are you sure they are the same?

  • EmployeeOcta Profile Picture
    6 on at

    Hello Wei,

    How come Guid be same on the two different instances of the CRM.

    only the passing of the correct values are important for object reference error.

    And i have checked whatever the required values are there those are passed.

    i didn't get which Guid's you are talking about. can you elaborate little.

  • Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi

    Share your code here.

  • EmployeeOcta Profile Picture
    6 on at

    this._stringParameterCheck(id, "SDK.REST.updateRecord requires the id parameter.");

     this._parameterCheck(object, "SDK.REST.updateRecord requires the object parameter.");

     this._stringParameterCheck(type, "SDK.REST.updateRecord requires the type parameter.");

     this._callbackParameterCheck(successCallback, "SDK.REST.updateRecord requires the successCallback is a function.");

     this._callbackParameterCheck(errorCallback, "SDK.REST.updateRecord requires the errorCallback is a function.");

     var req = new XMLHttpRequest();

     req.open("POST", encodeURI(this._ODataPath() + type + "Set(guid'" + id + "')"), true);

     req.setRequestHeader("Accept", "application/json");

     req.setRequestHeader("Content-Type", "application/json; charset=utf-8");

     req.setRequestHeader("X-HTTP-Method", "MERGE");

     req.onreadystatechange = function () {

      if (this.readyState == 4 /* complete */) {

       req.onreadystatechange = null;

       if (this.status == 204 || this.status == 1223) {

        successCallback();

       }

       else {

        errorCallback(SDK.REST._errorHandler(this));// Error Line

       }

      }

     };

     req.send(JSON.stringify(object));

  • Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi

    share more especially the part you get the value

  • EmployeeOcta Profile Picture
    6 on at

    These 3/4 values only i am sending to the system, not more than that.

    there is nothing extra that we are sendig.

    id contains Guid,

    object contains some text .

    that's it.

    also my execution flow do not takes me to the actual code line, it goes to somewhere else and then values reflect in the previous line, 

    is that asynchronous mode issue or something else.

  • Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    have you tried other records?

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Hi,

    What are you using SDK.REST and not WebApi?

    It seems like you are using CRM Online, which means you are most likely on v2016 or above?

    Download CRM REST Builder by Jason Lattimer, install it in your environment, and generate the correct web api call.

    You can download it from here: github.com/.../CRMRESTBuilder

    This will make this process much easier for you, and you can test it within the interface to see if you get the results.

    Hope this helps.

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