Home > Software engineering >  SharePoint REST API. 400 Bad Request when Making an AJAX call on SharePoint List
SharePoint REST API. 400 Bad Request when Making an AJAX call on SharePoint List

Time:12-20

Good Afternoon. I'm not sure what I'm doing wrong here. I have a REST API call on a SharePoint list and for the life of me cannot figure out why I'm getting a 400 Bad Request message. Here's my call....

myURL = "my sharepoint site URL"

$.ajax({
url: myURL   "/org/Analysis/_api/web/list/GetByTitle('Analysis')/items?$filter=Accepted eq 'Yes'&$select=Date_x0020_of_x0020_Activity, Accepted"
method: "GET"
headers:{"ACCEPT" : "application/json;odata=verbose",
"content-type":"application/json;odata=verbose"
},
// success function and some other stuff


});

Thank you in advance....

CodePudding user response:

Can you try with changing the code?

headers: { 
    "Accept": "application/json;odata=verbose",  
    "Content-Type": "application/json;odata=verbose",  
    "X-RequestDigest": $("#__REQUESTDIGEST").val()  
}

CodePudding user response:

You can refer to the following url

_api/web/list/GetByTitle('Analysis')/items?$select=Date_x0020_of_x0020_Activity,Accepted&$filter=Accepted eq 'Yes'
  • Related