Hello Augustin Chevrier
Thank you for posting question to Microsoft Q&A Forum.
According to this issue, I've conducted a research about this, mainly on these two articles:
https://learn.microsoft.com/en-us/graph/api/range-update?view=graph-rest-beta&tabs=javascript
https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/2499
From my perspective view after checking this, and your code - the explanation should be:
PatchAsync on Workbook.Names[rangeName] calls the named item PATCH endpoint, which only supports updating metadata (like comment or visible) and, for constant names, the value (formula).
It does not update the RefersTo property (the A1 reference for range-type names). The API does not expose a way to change the address of a named range via PATCH.
So:
-
PatchAsync(body)works for visibility or comment changes. - It fails for retargeting a named range because that property isn’t supported.
That's why your finding for this solution would result in deleting and add the name range. I could not find any official Microsoft Graph documentation that supports updating a named range’s reference (where it points) using PATCH. The API only allows updating metadata via PATCH, and the recommended approach for changing the reference is to delete the named item and add it again with the new address.
You might need to submit a feedback to Microsoft Graph section in Feedback portal: https://feedbackportal.microsoft.com/feedback/forum/ebe2edae-97d1-ec11-a7b5-0022481f3c80
As this feedback gains more votes, this should bring attention to back-end team to improve it in future Microsoft Graph update.
I hope this information is helpful. Please let me know if you have any further questions.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.