Forum Discussion
Chirag Shah
Aug 30, 2018Copper Contributor
Rest API - Fetch Data using POST method and CamlQuery and Lookup Column
Hello, I am trying to get Username(Display name) from YourName field which is Person type field. But When I get result, I get ID as YourNameId. How can I get name rather than Id with using follow...
- Sep 07, 2018
I got the solution. I used the POST method to fetch data from the list
My actual query is around 384 characters long.
I think this post can be helpful to anyone who is seeking a solution using the POST method and without the character limit.
When using $expand all the lookup columns must expand using FieldValuesAsText/ColumnName.https://contoso.sharpeoint.com/_api/web/lists/GetByTitle('JourneyDetails')/GetItems?$select=*,FieldValuesAsText/YourName,FieldValuesAsText/Author&$expand=FieldValuesAsText&$filter=SupervisorApprovalStatus eq 'Approved' and TravelDepartmentApprovalStatus ne 'Approved' and TravelDepartmentApprovalStatus ne 'Rejected'
Rishi Gupta
Aug 30, 2018Brass Contributor
Why are you using REST and CAML together. Looking at the query below, you can retrieve the values using REST api itself.
Try using $expand in the REST query to expand the column values. $expand can be used with User/Lookup/Choice fields etc to get the values instead of ID's.
https://contoso.sharepoint.com/_api/web/lists/GetByTitle('JourneyDetails')/GetItems?$select=*,Author/Title&$expand=Author