0

I want to query my custom list using REST API + CAML. And I have to use POST request to be able to get the managed metadata values (mainly Label), so I tried the below Ajax request:

var body = { 
       'query':{ 
           '__metadata': { 'type': 'SP.CamlQuery' },
           'ViewXml': "<View><Query><Where><Eq><FieldRef Name='Id'/><Value Type='Number'>"+orderID+"</Value></Eq></Where></Query></View>"
        } 
   };   
    $.ajax({
     url: "/*****/_api/web/lists/getbytitle('*****')/GetItems",
     method: "POST",   
     contentType : "application/json;odata=verbose",     
     async: false,
     data: JSON.stringify(body),
     headers: { 
        "Accept": "application/json; odata=verbose",
        "X-RequestDigest": $('#__REQUESTDIGEST').val()       
     },
     success: function (data) {
         if(data.d.results.length>0){

            var items=data.d.results;

            for(var i=0;i<items.length;i++){
               //code goes here

            }
            console.log(data);

         }

      }  
    });

but I got the following exception:

One or more field types are not installed properly. Go to the list settings page to delete these fields.

So can anyone advice on the above error? Although the list have a field named Id of type Number.

2
  • 1
    Use ID instead of Id and check Jun 5, 2018 at 13:35
  • @GautamSheth i got lost on this as inside the REST API result the ID will be as follow <d:Id m:type="Edm.Int32">417</d:Id> so ithought i need to use Id!!
    – John John
    Jun 5, 2018 at 13:38

1 Answer 1

1

CAML query requires InternalName of the field. So Id is reserved for item's ID

If you want to get an item by id then url: "/*****/_api/web/lists/getbytitle('*****')/items("+orderID+")"

And rename your field.

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.