pythonsharepointpython-requestsmicrosoft-graph-api

Requesting worksheet cell values using Graph API + Python


Below is a snippet of my code. Using the requests library.

url = 'https://graph.microsoft.com/v1.0/sites/' + siteid+ '/drive/items/' + itemid + 'workbook/worksheets/Sheet1/range/cell(row=5,column=6)'
headers = {
  'Authorization': 'Bearer ' + access_token
}

# Make a GET request to the provided url, passing the access token in a header
graph_result = requests.get(url=url, headers=headers)

# Print the results in a JSON format
print(graph_result.json())

Getting the following error and I have no idea how to resolve.

{'error': {'code': 'BadRequest', 'message': "Open navigation properties are not supported on OpenTypes. Property name: 'cell'.", 'innerError': {'date': '2024-07-23T19:42:36', 'request-id': 'e257e0b8-5204-4ab6-aaea-e5d72d96bb1a', 'client-request-id': 'e257e0b8-5204-4ab6-aaea-e5d72d96bb1a'}}}

I expect to get json back with the cell value contained. Requested the item id by itself and it does respond correctly. I don't know how to fix the Open Navigation properties are not supported on OpenTypes error.


Solution

  • I think you are missing slash / before workbook in the URL path.

    url = 'https://graph.microsoft.com/v1.0/sites/' + siteid+ '/drive/items/' + itemid + '/workbook/worksheets/Sheet1/range/cell(row=5,column=6)'