0

I've never seen this error before and I've used REST API many times. I am in SharePoint Online so maybe it behaves differently.

Whenever I insert and item into a list using REST, I get the following error and I don't know why.

enter image description here

Here's a snippet of my code

 $.ajax({
  url: fullUrl,
  method: "POST",
  data: JSON.stringify({
    '__metadata': { 'type': 'SP.Data.Historical_x0020_RegisterListItem' },   //SP.Data.Historical_x0020_RegisterListItem /rr/_api/web/lists/GetByTitle('Register')/ListItemEntityTypeFullName
    'Register': that.register,  //choice column
    'RiskRegister': that.riskRegister,  //choice column
    'Reopen': this.formatDate(that.reopen),  //date column
    'RiskOrIssue': that.riskOrIssue,  //date column
    'Status': that.status,  //choice column
    'problemT': that.probTitle,  //single line of text column
    'ProblemStatement': that.problemStatement,  //multi-line text
    'TaskOwner': that.taskOwner,        //single line of text 
    'Probability': that.probability,  //single line of text
    'Impact': that.impact  //single line of text
  }),
  headers: {
    "accept": "application/json;odata=verbose",
    "content-type": "application/json;odata=verbose",
    "X-RequestDigest": $("#__REQUESTDIGEST").val()
  },
  success: function(){
    alert("Item Added!");
  },
  error: function(data){
    console.log(data);
  } 
  });

Any help with this would be greatly appreciated. Thank you!

1 Answer 1

0

Human error on my part. The value to be updated was in lowercase and not capital. Here's the correction:

  'Register': that.Register,  //choice column
    'RiskRegister': that.RiskRegister,  //choice column
    'Reopen': this.formatDate(that.Reopen),  //date column
    'RiskOrIssue': that.RiskOrIssue,  //date column
    'Status': that.Status,  //choice column
    'problemT': that.ProbTitle,  //single line of text column
    'ProblemStatement': that.ProblemStatement,  //multi-line text
    'TaskOwner': that.TaskOwner,        //single line of text 
    'Probability': that.Probability,  //single line of text
    'Impact': that.Impact//single line of text

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.