SharePoint REST API Get List Items with drop down values

Ashish Sinha 161 Reputation points
2021-05-14T12:55:02.463+00:00

Hi All,

I have to get the list items in SharePoint and load it to synapse.
What I have done till now is this:

import json
import sharepy
s = sharepy.connect("https://mysite.sharepoint.com", username="username", password="password")
r = s.get("https://mysite.sharepoint.com/_api/web/lists/GetByTitle('ListName')/items")
data = json.loads(r.text)

dict1 = {}
for i in data['d']['results']:
    dict1['Title'] = i['Title']
    dict1['Date Requested'] = i['DateRequested']
    dict1['Requestor'] = i['RequestorId']
    dict1['Date Due'] = i['DateDue']
    dict1['Status'] = i['Status']
    dict1['CategoryId'] = i['CategoryId']
    dict1['Request Type'] = i['Request_x0020_TypeId']

I login to Sharepoint and get my list items and load it as json format into data variable and wants to fetch some values from that json.

But the issue is that the header "Requestor" is a name of a person which is what we select from drop down but in json it comes as an integer number and similary I have a Field with LookUp Value. So basically what I have is Microsoft.SharePoint.Client.FieldLookupValue and Microsoft.SharePoint.Client.FieldUserValue.

How can i extract the actual data instead of these numeric or formulas? Thanks

Ashish

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,159 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,784 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ashish Sinha 161 Reputation points
    2021-05-14T17:27:27.267+00:00

    Hi Guys,

    Meanwhile, I was searching for the answer and I found something.
    So in the JSON that was returned in the above code had a key named: FieldValuesAsText.
    When I put that in the URL for a particular Item in a List I get all the field values in an XML Format.
    If I parse this and fetch the fields that would give me what i want to do.

    Thanks


0 additional answers

Sort by: Most helpful