In alert I am getting value in data.d.results[0](This is the value that I am getting from other list using rest).Subsystem.Title and also if I use only title column then the value is inserted in the list but when I use a lookup column i.e. Subsystem, then it goes to error function.

        url: "https://sharepoint.com/teams/_api/web/lists/GetByTitle('Features')/Items",
        type: "POST",
        data:  JSON.stringify({ '__metadata': { 'type': 'SP.Data.FeaturesListItem' }, 
  'Title': data.d.results[0].Title,'Subsystem':data.d.results[0].Subsystem.Title}),
        headers: { 
            "accept": "application/json;odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val()
        success: function(d) {alert("Items Inserted!"); 
        error: function() {alert("Failed to Insert Items!");}
  • 1
    What is the difference between a Title column and a Lookup column????? – Danny '365CSI' Engelman Nov 14 '15 at 9:59

For lookup type column, the value will be Integer and must be the ID of Lookup item. In the request body, you have to specified it as

InternalNameOfTheColumn + Id

Meaning that, If your column's internal name is Subsystem, in the request, it will be SubsystemId. Value of SubsystemId will be an Integer (Id of the lookup item).

JSON.stringify({ '__metadata': { 'type': 'SP.Data.FeaturesListItem' }, 
  'Title': data.d.results[0].Title,'SubsystemId':"It will be integer"})

See more details, in my article.

CRUD Operation to List Using SharePoint 2013 Rest API

  • How would I know the ID for the items in the lookup column? – KumarV Nov 14 '15 at 12:10
  • you can get IDs using another REST call. /_api/web/lists/GetByTitle('Name of the lookup list')/Items?$select=ID – Atish Dipongkor - MVP Nov 14 '15 at 17:10
  • where do I need to call this again? – KumarV Nov 14 '15 at 17:32
  • You have to make this call first to get all lookup ids. then you will make another call where SubsystemId will be one of the id from lookup ids. – Atish Dipongkor - MVP Nov 15 '15 at 3:42
  • m new to rest api, can u pls help me with an example code.. – KumarV Nov 15 '15 at 5:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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