Adding Sharepoint Lookup Item With Graph

%3CLINGO-SUB%20id%3D%22lingo-sub-69892%22%20slang%3D%22en-US%22%3EAdding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-69892%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20experimenting%20with%20Graph%20(Beta)%20with%20Sharepoint.%20I%20can%20create%20items%20and%20update%20their%20fields.%20It%20works%20for%20simple%20%26nbsp%3Bfields%20like%20text%20andnumbers.%20Howerver%2C%20I%20can't%20figure%20out%20how%20to%20update%20fields%20like%20lookup%20and%20the%20one%20with%20multiple%20values.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20read%20an%20item%20and%20look%20at%20a%20lookup%20field%2C%20it%20looks%20like%20this%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%22Predecessors%22%3A%20%5B%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%22LookupId%22%3A%2080%2C%3CBR%20%2F%3E%22LookupValue%22%3A%20%22Create%20general%20slides%20masters%22%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%5D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20do%20the%20same%20format%20(but%20only%20the%20LookupId%20portion)%20with%20a%20PATCH%20request%20and%20the%20right%20url%2C%20it%20gives%20e%20malformed%20request.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnyone%20knows%20how%20to%20form%20the%20request%20for%20these%20more%20complex%20types%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EEtienne%20Fortin%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-389280%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-389280%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F53196%22%20target%3D%22_blank%22%3E%40Etienne%20Fortin%3C%2FA%3E%26nbsp%3BThe%20key%20is%20to%20append%20%22LookupId%22%20to%20the%20column%20name.%20So%20if%20the%20lookup%20column%20name%20is%20%22%3CSPAN%3EPredecessors%22%2C%20then%20insert%20the%20following%20JSON%3A%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%22PredecessorsLookupId%22%3A%2080%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3ESee%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F238346%2Fhow-to-do-microsoft-graph-api-filter-on-lookup-column-in-sharepoint-list-items%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fsharepoint.stackexchange.com%2Fquestions%2F238346%2Fhow-to-do-microsoft-graph-api-filter-on-lookup-column-in-sharepoint-list-items%3C%2FA%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-103838%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-103838%22%20slang%3D%22en-US%22%3EI'm%20sorry%20if%20I%20was%20unclear%2C%20but%20no%2C%20I%20have%20not%20gotten%20update%20to%20work%20(nor%20tried%20to)%20either.%20I%20just%20get%20the%20same%20errors%20as%20you.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-103836%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-103836%22%20slang%3D%22en-US%22%3E%3CP%3ENo%20I%20didn't.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20you%20mention%20being%20able%20to%20update%20a%20lookup%20item%3F%20How%20do%20you%20proceed%3F%20How%20did%20you%20make%20it%20work.%20I%20can't%20update%20either.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-103834%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-103834%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20getting%20a%20non%20null%20response%20to%20my%20queries.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-103832%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-103832%22%20slang%3D%22en-US%22%3E%3CP%3EDid%20you%20find%20an%20answer%20yet%3F%20Having%20the%20same%20issue%2C%20only%20when%20creating%20an%20item%20instead%20of%20updating%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-98352%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-98352%22%20slang%3D%22en-US%22%3E%3CP%3EToo%20bad%20%3A(%3C%2Fimg%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBut%20are%20you%20successfully%20calling%20the%20view-items%20endpoint%3A%26nbsp%3B%3C%2FP%3E%3CPRE%3E%2Fbeta%2Fsites%2F%7Bsite-id%7D%2Flists%2F%7Blist-id%7D%2Fitems%3C%2FPRE%3E%3CP%3E%26nbsp%3Band%20getting%20a%20non-null%20response%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBecause%20all%20I%20get%20as%20a%20response%20is%3A%3C%2FP%3E%3CPRE%3E%7B%0A%20%20%20%20%22%40odata.context%22%3A%20%22https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2F...%22%2C%0A%20%20%20%20%22value%22%3A%20%5B%5D%0A%7D%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-98052%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-98052%22%20slang%3D%22en-US%22%3E%3CP%3EYes%2C%20I%20did.%20I%20used%20%22Id%22%2C%20and%20%22ID%22.%20No%20success.%20I%20used%20the%20field%20name%20for%20the%20value%20field%2C%20without%20the%20Id%20suffix.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-98048%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-98048%22%20slang%3D%22en-US%22%3Ejust%20pass%20the%20value%20like%20you%20would%20a%20string%3CBR%20%2F%3E%3CBR%20%2F%3EMaybe%20if%20your%20lookup%20is%20called%20%22lookupField%22%2C%20I%20think%20it%20uses%20a%20secondary%20internal%20fieldname%20with%20%22Id%22%20appended%20to%20the%20end%20of%20it.%20This%20is%20how%20we%20have%20to%20do%20it%20for%20csom%20or%20spd%20web%20services%2C%20so%20I'd%20imagine%20its%20the%20same%20for%20Graph.%3CBR%20%2F%3E%3CBR%20%2F%3E%22lookupFieldId%22%3A%20%2280%22%2C%3CBR%20%2F%3E%3CBR%20%2F%3Eor%3CBR%20%2F%3E%3CBR%20%2F%3E%22lookupFieldId%22%3A%2080%2C%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-98045%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-98045%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20not%20sure%20I%20understand.%20Can%20you%20put%20out%20a%20json%20quick%20exemple%20of%20the%20PATCH%20http%20request%20that%20would%20follow%20what%20you%20are%20suggesting%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-98021%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-98021%22%20slang%3D%22en-US%22%3EFor%20the%20lookup%2C%20have%20you%20tried%20JUST%20passing%20the%20Integer%20value%20of%20the%20target%20item%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-97986%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-97986%22%20slang%3D%22en-US%22%3E%3CP%3EUnfortunetely%20not.%20Can't%20figure%20out%20how%20to%20do%20it.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-94136%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-94136%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20now%20faced%20with%20the%20same%20task%2C%20did%20you%20figure%20out%20how%20to%20do%20it%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2094097%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2094097%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F53196%22%20target%3D%22_blank%22%3E%40Etienne%20Fortin%3C%2FA%3E%26nbsp%3BHave%20you%20found%20a%20solution%20to%20this%20issue%3F%20I%20am%20experiencing%20the%20same%20problem.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2207345%22%20slang%3D%22en-US%22%3ERe%3A%20Adding%20Sharepoint%20Lookup%20Item%20With%20Graph%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2207345%22%20slang%3D%22en-US%22%3Ethat%20is%20exactly%20what%20I%20was%20looking%20for%20thanks%3C%2FLINGO-BODY%3E
Occasional 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