0

I have a query in REST API which is :

var i = _spPageContextInfo.webAbsoluteUrl + "/_api/web/Lists/GetByTitle('Pages')/GetItems(query=@v1)?@v1={"ViewXml":"<View Scope='RecursiveAll'><Query><Where><And><BeginsWith><Fieldref Name='ContentTypeId' /><Value Type='ContentTypeId'>Content type value here</Value></BeginsWith><And><Eq><FieldRef Name='FieldNameHere' /><Value Type='Boolean'>0</Value></Eq><Eq><FieldRef Name='SomeFieldName' /><Value Type='Boolean'>0</Value><Eq></And></And></Where><OrderBy><FieldRef Name='SomeField' Ascending='False' /></OrderBy></Query></View>"}" 

As you can see this is a POST call and not a GET call. I need to change this to a GET call since POST is giving me permission related issues, in that the above query will only work for people with Contribute and above level permissions. It won't work for People with Read Access.

One option I thought would be to use the "items" API query but I'm not sure how I can pass the above Caml Query to it

var i = _spPageContextInfo.webAbsoluteUrl + "/_api/web/Lists/GetByTitle('Pages')/items?CamlQueryConditionhere?$select=Fields.."

Any Help would be appreciated

1 Answer 1

1

The POST itself should not cause permission related issues. Are you getting a 403 back from the request? There's probably another reason why you're getting access denied.

The CamlQuery method is not supported over GET - to do a GET you'll need to use the OData operators. You should be able to AND two conditions to achieve what you're looking for.

https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/use-odata-query-operations-in-sharepoint-rest-requests

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.