Adding Sharepoint Lookup Item With Graph

Copper Contributor

I'm experimenting with Graph (Beta) with Sharepoint. I can create items and update their fields. It works for simple  fields like text andnumbers. Howerver, I can't figure out how to update fields like lookup and the one with multiple values.

 

If I read an item and look at a lookup field, it looks like this:

 

  "Predecessors": [
{
"LookupId": 80,
"LookupValue": "Create general slides masters"
}
]

 

If I do the same format (but only the LookupId portion) with a PATCH request and the right url, it gives e malformed request. 

 

Anyone knows how to form the request for these more complex types?

 

Etienne Fortin 

14 Replies

I am now faced with the same task, did you figure out how to do it?

Unfortunetely not. Can't figure out how to do it.

For the lookup, have you tried JUST passing the Integer value of the target item?

I'm not sure I understand. Can you put out a json quick exemple of the PATCH http request that would follow what you are suggesting?

just pass the value like you would a string

Maybe if your lookup is called "lookupField", I think it uses a secondary internal fieldname with "Id" appended to the end of it. This is how we have to do it for csom or spd web services, so I'd imagine its the same for Graph.

"lookupFieldId": "80",

or

"lookupFieldId": 80,

Yes, I did. I used "Id", and "ID". No success. I used the field name for the value field, without the Id suffix.

Too bad :( 

 

But are you successfully calling the view-items endpoint: 

/beta/sites/{site-id}/lists/{list-id}/items

 and getting a non-null response? 

 

Because all I get as a response is:

{
    "@odata.context": "https://graph.microsoft.com/beta/...",
    "value": []
}

 

Did you find an answer yet? Having the same issue, only when creating an item instead of updating

I'm getting a non null response to my queries.

No I didn't.

 

But you mention being able to update a lookup item? How do you proceed? How did you make it work. I can't update either.

I'm sorry if I was unclear, but no, I have not gotten update to work (nor tried to) either. I just get the same errors as you.

@Etienne Fortin The key is to append "LookupId" to the column name. So if the lookup column name is "Predecessors", then insert the following JSON:

 

 "PredecessorsLookupId": 80,

 

See https://sharepoint.stackexchange.com/questions/238346/how-to-do-microsoft-graph-api-filter-on-lookup...

@Etienne Fortin Have you found a solution to this issue? I am experiencing the same problem. 

that is exactly what I was looking for thanks