I am unable to create or update a SharePoint Online listitem
that contains a hyperlink field using Microsoft Graph. I can create or update items to the same list if I remove the hyperlink field from the body of the API call.
For update, I am sending a PATCH request to:
/v1.0/sites/<site>/list/<listid>/items/<item>/fields
with the following headers:
"Authorization" : "Bearer <token>"
"accept" :"application/json;odata.metadata=full;odata.streaming=true"
Here is the body:
{
"myUrl": {
"Description": "http://www.google.com",
"Url": "http://www.google.com"
}
}
I will get the following error message in response:
{
"error": {
"code": "invalidRequest",
"message": "The request is malformed or incorrect.",
"innerError": {
"request-id": "cfe30f57-31ba-4341-89e9-2c1bd4e15539",
"date": "2017-11-10T21:55:30"
}
}
}
It is worth noting that I can update other fields in the list item using the exact headers and target URL, as long as there is not a hyperlink field in the json body.
The format I am sending is the exact format I receive the URL field in when I do a GET
. Does anyone know the appropriate format for sending URL fields back to SharePoint?
Update 1/8/2018
I posted this same issue to Microsoft's Graph Github on 11/11/2017 and they have yet to provide an answer. I have heard unofficially that REST operations on listitems that have a nested structure (e.g. hyperlink, user, taxonomy) are not supported at this time. Here is a link to the issue just in case they answer it later: https://github.com/microsoftgraph/microsoft-graph-docs/issues/1965
I do have a workaround for hyperlink fields that I am using. I changed the column on the SharePoint List that was previously a hyperlink to a "Single line of text" field. When a hyperlink is entered in a Single line text field, it is showing as a underlined and clickable link when you view the event in a browser. You can't use alternate text if you have a long and ugly URL like with the hyperlink field type, but it works!