At the moment I am trying to use Microsoft Graph API via python requests library to update who has access to certain files on Sharepoint.
I am passing the site_id , item_id, and user_id into my function which results in the following error:
"error":{"code":"invalidRequest","message":"Invalid request"}
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
permission_data = {
'grantedToIdentitiesV2': [{
'user': {
'id': user_id
}
}],
"roles": ["read"]
}
payload = json.dumps(permission_data)
endpoint = f"https://graph.microsoft.com/v1.0/sites/{site_id}/drive/items/{item_id}/permissions"
response = requests.post(endpoint, headers=headers, data=payload)
Not sure if I am able to post to this endpoint based on the info here:
https://learn.microsoft.com/en-us/graph/api/resources/permission?view=graph-rest-1.0
So wondering if anyone know how I would go about this request?