2

I am using REST Api to get sharepoint List items.

Now I am trying to retrieve all filtered list items where status is completed.

But i was getting 400 request error

I was fire query like below.

https://MySiteName/_api/lists/getbytitle('MyList')/items?$select=Title,ID,Status&$filter=Status eq 'Completed' 
  • The query you fired should work. Make sure, that the listname ('MyList') is correct and make sure the column Status is really called Status and the field value is really called Completed. Also you could first check it without everthing after /items – Patrick Feb 29 '16 at 10:31
1

Try this below code its working for me,

     /_api/web/lists/GetByTitle('Listname')/items?$select=Title,ID,Status$filter=Status eq 'Completed'


    /_api/Web/Lists(guid'GUID')/Items?$select=Title,ID,Status$filter=Status eq 'Completed'
1

I tested it, and in my environment it is working. SharePoint 2013 on-prem.

Listname:

MyList

Columns:

Title (by default included)

ID (by default included)

Status -> Dropdown -> Fieldvalues -> Open, Completed

enter image description here

After entering the query in browser I get:

enter image description here

As far as I understood here: https://msdn.microsoft.com/en-US/library/office/fp142380.aspx

It should not make a difference for your requirement. Snippet:

To access a specific site collection, use the following construction:

http://server/site/_api/site

To access a specific site, use the following construction:

http://server/site/_api/web

  • no its not work for me. dont know why – Vishal Thakkar Feb 29 '16 at 10:40
  • when i remove filter then its work well then its not give 400 error – Vishal Thakkar Feb 29 '16 at 10:52
  • Which version of SharePoint are you using? – Patrick Feb 29 '16 at 11:02
  • As per Patrick, Please let us know which version of SharePoint (with Updates details ) are you using? – Shantha Kumar Thambidurai Feb 29 '16 at 11:09
  • office 365 2013 – Vishal Thakkar Feb 29 '16 at 11:10
1

Finally i got solution i am passing in URL so URL never contain white space it so i change like this and its work for me

https://MySiteName/_api/lists/getbytitle('MyList')/items?$select=Title,ID,Status&$filter=Status+eq+'Completed' 
0

I think it needs to be

https://MySiteName/_api/web/lists/getbytitle('MyList')/items?$select=Title,ID,Status&$filter=Status eq 'Completed'

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.