Python请求在Sharepoint中发布JSON原始数据

时间:2020-02-06 09:37:03

标签: python json sharepoint

我想更新Sharepoint项中的某些属性。

我正在使用以下代码:

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'
: '*'}

然后我打电话:

import requests


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

但是我总是得到相同的答案:

{'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'."}}}

有人可以给我关于这个问题的任何线索吗?

以前,我在Postman上建立了类似的请求,该请求成功完成 enter image description here

感谢和亲切问候

0 个答案:

没有答案
相关问题