I want to insert a billet item list with related category ID in REST API Sharepoint.
I proceeded as follows:
POST /_api/lists/getbytitle('Billets')/items
{ "__metadata": { "type": "SP.Data.BilletsListItem" }, "Title": "Mise à jour", "PublishedDate": "2016-05-06T10:52:00Z", "Body": "test", "PostCategory": 2 } } Error:
{ "error": { "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException", "message": { "lang": "fr-FR", "value": "Un nœud 'PrimitiveValue' avec une valeur non-Null a été trouvé lors de la tentative de lecture de la valeur d'une propriété de navigation ; pourtant, un nœud 'StartArray', un nœud 'StartObject' ou un nœud 'PrimitiveValue' avec une valeur Null était attendu." } } } Without PostCategory parameter in the JSON the item is added successfully but without category.
Here the description of PostCategory field :
"__metadata": { "id": "/_api/Web/Lists(guid'd67d1f54-aab5-460d-905d-a904553975e6')/Fields(guid'38bea83b-350a-1a6e-f34a-93a6af31338b')", "uri": "/_api/Web/Lists(guid'd67d1f54-aab5-460d-905d-a904553975e6')/Fields(guid'38bea83b-350a-1a6e-f34a-93a6af31338b')", "type": "SP.FieldLookup" }, "CanBeDeleted": false, "DefaultValue": null, "Description": "", "Direction": "none", "EnforceUniqueValues": false, "EntityPropertyName": "PostCategory", "Filterable": true, "FromBaseType": false, "Group": "Colonnes personnalisées", "Hidden": false, "Id": "38bea83b-350a-1a6e-f34a-93a6af31338b", "Indexed": false, "InternalName": "PostCategory", "JSLink": "clienttemplates.js", "ReadOnlyField": false, "Required": false, "SchemaXml": "<Field Name=\"PostCategory\" Type=\"LookupMulti\" DisplayName=\"Catégorie\" List=\"{81E335A6-8361-4883-A835-C5E1C6B0E67B}\" Mult=\"TRUE\" ShowField=\"Title\" ID=\"{38bea83b-350a-1a6e-f34a-93a6af31338b}\" Sortable=\"FALSE\" Sealed=\"TRUE\" SourceID=\"http://schemas.microsoft.com/sharepoint/v3\" StaticName=\"PostCategory\" ColName=\"int2\" RowOrdinal=\"0\" />", "Scope": "/Lists/Billets", "Sealed": true, "Sortable": false, "StaticName": "PostCategory", "Title": "Catégorie", "FieldTypeKind": 7, "TypeAsString": "LookupMulti", "TypeDisplayName": "Recherche", "TypeShortDescription": "Recherche (informations déjà sur ce site)", "ValidationFormula": null, "ValidationMessage": null, "AllowMultipleValues": true, "IsRelationship": true, "LookupField": "Title", "LookupList": "{81E335A6-8361-4883-A835-C5E1C6B0E67B}", "LookupWebId": "74bab6ac-e483-456b-9a8a-7c7fb279c4b7", "PrimaryFieldId": null, "RelationshipDeleteBehavior": 0 } How can I add category Id in my post JSON request ?