I want to update some property in a SharePoint ListItem.

I'm using this code:

body = '{"__metadata": {"type": "SP.Data.Documentos_x0020_compartidosItem"}, "Tarea": "TP 15"}'
header = {'Authorization': 'Bearer ' + bearer + '', 'Accept': 'application/json;odata=verbose', 'X-HTTP-Method':'MERGE','content-type': 'application/json', 'IF-MATCH'
: '*'}

and I make this call:

requests.post("https://[sharepoint URL]/_api/web/lists/GetByTitle('Documentos')/items(232)",json=body,headers=header).json()

but I get always the same answer:

{'error': {'code': '-1, '
           'message': {'lang': 'es-ES',
                       'value': "Se encontró un nodo 'PrimitiveValue' "
                                'inesperado al leer del lector JSON. Se '
                                "esperaba un nodo 'StartObject'."}}}

Value translation: "An unexpected 'PrimitiveValue' node was found when reading from the JSON reader. It was expected a 'Startobject' node"

Could anyone give me any clue about this issue?

Previously I built similar request on Postman and it worked succesffully: enter image description here

Thanks and kind regards

  • What is the column Type of Tarea? Can you please share the screenshot of your list column types? Feb 6 '20 at 11:16
  • For sure! it's just a customized column Here you have a screenshot: ibb.co/1T1X5Kx Feb 6 '20 at 11:35
  • Is Tarea or Zone any of them are lookup columns? Feb 6 '20 at 11:46
  • I'm not sure enough what you mean with "lookup columns". Sorry, my knowledge about SharePoint is pretty elemental. For me they are either customized or personal columns. How could I confirm that feature? I must say I haven't found any problem to update those customized columns from Postman Feb 6 '20 at 11:50
  • Kindly share the screenshot of the list settings under which columns are listed. Feb 6 '20 at 11:51

You have your Accept set this way, but in order to POST/PUT/PATCH metadata in that format, your content-type also needs to be set to 'content-type': 'application/json;odata=verbose'.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.