Jan Hajek
Jan Hajek

Reputation: 668

Unable to update Hyperlink or Picture in SharePoint via Microsoft Graph

I am trying to update a value on a list item (type is Hyperlink or Picture). When performing GET requests, the data return fine, but when I try to create an item or udpate it with the value I end up with following:

{
    "error": {
        "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
        "message": "A value without a type name was found and no expected type is available. When the model is specified, each value in the payload must have a type which can be either specified in the payload, explicitly by the caller or implicitly inferred from the parent value.",
        "innerError": {
            "request-id": "d12dfb12-a068-4621-9f27-d284e4635060",
            "date": "2019-05-28T08:52:51"
        }
    }
}

The POST/PATCH request goes to:

https://graph.microsoft.com/v1.0/sites/<siteid>/lists/<listid>/items/

and contains a simple JSON (in case of PATCH):

{
  "WebPage":
  {
    "Description": "Microsoft Graph",
    "Url": "http://graph.microsoft.com"
  }
}

Any idea what I am doing wrong? I tried with .NET SDK and Graph Explorer and it ends with the same error...

Upvotes: 8

Views: 422

Answers (1)

KMR
KMR

Reputation: 808

For updates to items in a list you need to supply the ID as part of the URI, it should look like this:

PATCH https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}

The error you're getting is the one returned when trying to update a collection with an object that Graph cannot reconcile to that collection.

Upvotes: 0

Related Questions