2

I am pass data like below. where Company name is Multi lookup Field.

{"Address":"","CompanyName":[{"ID":2,"Title":"InfoEngg"}],"Email":"[email protected]","Title":"Kapil","Mobileno":"9898989898","Password":"Sp@12345","EmpRole":"Level 1"}

Why this error throw?? how can i solve it?

1
  • Make sure you are passing value for all required column in REST API data(JSON) Jan 22, 2018 at 15:33

1 Answer 1

2

Try changing your CompanyName field to:

"CompanyNameId": {
    "__metadata": {
        "type": "Collection(Edm.Int32)"
    },
    "results": [ 2 ] // Array of the IDs of your selected items
}

Since per your comment your data format is set, why not just transform it before sending your update?

var data = {"Address":"","CompanyName":[{"ID":2,"Title":"InfoEngg"}],"Email":"[email protected]","Title":"Kapil","Mobileno":"9898989898","Password":"Sp@12345","EmpRole":"Level 1"};

var updateData = {
  Address: data.Address,
  CompanyNameId: {
    "__metadata": {
      "type": "Collection(Edm.Int32)"
    },
    "results": $.map(data.CompanyName, function(c) { return c.ID; })
  },
  Email: data.Email,
  Title: data.Title,
  Mobileno: data.Mobileno,
  Password: data.Password,
  EmpRole: data.EmpRole
};
2
  • i know this way but i have pojo class it contains all data for that lookup Jan 23, 2018 at 5:52
  • 1
    Well, you asked why you're getting an error, and that's why. The service is expecting CompanyNameId and it's not there. :)
    – Chris Romp
    Jan 23, 2018 at 5:55

Your Answer

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

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