Set value for Multiple Lookup list in sharepoint in C#

陌路散爱 提交于 2020-01-16 18:18:28

问题


I try to set the sharepoint list items and update lists, right now the sharepoint list is a lookup with multiple value
I call
POST /sites/{}/lists/{list_guid}/items/{item_id}/fields
with Json

{
    "MyListLookUpValue":[
          "LookupId":1,
          "LookupValue":"My name",
          "Email":"my@email.se",
     ]
}


(This isn't the code i use, but a representation)
I have found that i should specify the type but the thing is that i dont know the typ if it would be a list of Strings i could add

"MyListLookUpValue@odata.type":"Collection(Edm.String)"

Anyone that has this similar issue that you have to specify the type ?
Dont understand why they need to make it so hard.

{
"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": "2aaa2c86-f922-414b-b9c9-f892588b0bea",
        "date": "2019-02-28T17:05:05"
    }
}

}

SOLUTION
After help from comments i got this answer which worked

{
    "MyListLookUpValueLookupId@odata.type" : "Collection(Edm.Inte32)"
    "MyListLookUpValueLookupId": [1,2,3]
}

来源:https://stackoverflow.com/questions/54929817/set-value-for-multiple-lookup-list-in-sharepoint-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!