Hello Doug Horton,
Thank you for reaching out to Microsoft Support!
It looks like you’re on the right track with your PowerShell script! The issue you’re encountering with the PATCH requests might be due to the specific endpoint you’re using or the format of your request body. Here are a few steps and tips to help you troubleshoot and resolve the issue:
- Correct Endpoint:
- For updating custom columns in a SharePoint Document Library, you should use the following endpoint:
PATCH https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/fields
- Ensure that you replace
{site-id}
,{list-id}
, and{item-id}
with the actual IDs.
- For updating custom columns in a SharePoint Document Library, you should use the following endpoint:
- Request Body Format:
- The request body should be a JSON object with the fields you want to update. Make sure the field names match the internal names of the columns in your SharePoint list. Here’s an example:
{ "Position": "XXX", "City": "XXXXXXXX", "Email": "[email protected]", "State": "XX", "Zip": "XXXXX", "Address": "XXXXXXXXXXX" }
- The request body should be a JSON object with the fields you want to update. Make sure the field names match the internal names of the columns in your SharePoint list. Here’s an example:
- Common Issues:
- 400 Bad Request: This usually indicates a problem with the request format, or the data being sent. Double-check the JSON structure and ensure all required fields are included.
- 404 Not Found: This typically means the endpoint URL is incorrect or the item does not exist. Verify the IDs used in the URL.
- Permissions:
- Ensure that the access token you’re using has the necessary permissions to update items in the SharePoint list. You might need permissions like
Sites.ReadWrite.All
.
- Ensure that the access token you’re using has the necessary permissions to update items in the SharePoint list. You might need permissions like
Please refer to below screenshot.
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.