0

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, '
                   'Microsoft.SharePoint.Client.InvalidClientQueryException',
           '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

10
  • What is the column Type of Tarea? Can you please share the screenshot of your list column types? Commented Feb 6, 2020 at 11:16
  • For sure! it's just a customized column Here you have a screenshot: ibb.co/1T1X5Kx Commented Feb 6, 2020 at 11:35
  • Is Tarea or Zone any of them are lookup columns? Commented Feb 6, 2020 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 Commented Feb 6, 2020 at 11:50
  • Kindly share the screenshot of the list settings under which columns are listed. Commented Feb 6, 2020 at 11:51

1 Answer 1

0

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'.

1
  • Thanks willman I have tried your suggestion but the answer is the same. ibb.co/MCRQkk5 Commented Feb 6, 2020 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.