3

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' 
1
  • 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, 2016 at 10:31

6 Answers 6

2

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

8
  • no its not work for me. dont know why Feb 29, 2016 at 10:40
  • when i remove filter then its work well then its not give 400 error Feb 29, 2016 at 10:52
  • Which version of SharePoint are you using?
    – Patrick
    Feb 29, 2016 at 11:02
  • As per Patrick, Please let us know which version of SharePoint (with Updates details ) are you using? Feb 29, 2016 at 11:09
  • office 365 2013 Feb 29, 2016 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'
0

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

You missed 'web' before /lists/

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

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

you should remove guid before '' like this:

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

for example :

 /_api/web/lists('%7B326038AE-D47E-454D-AAD4-5440E6133EF2%7D')

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.