|
[云开发]
python中通过数据云API更新数据失败
[复制链接]
本帖最后由 RonnieTsang 于 2015-2-14 13:21 编辑
我想要更新数据云的数据,在python中这样写
... url = "https://d.apicloud.com/mcm/api/" + classname + "/" + objectId body = {'fieldname': fieldvalue} http = httplib2.Http() response, content = http.request(url, 'PUT', body=urllib.urlencode(body), headers={ 'content-type': 'application/json', 'X-APICloud-AppId': appId, 'X-APICloud-AppKey': appKey } )
结果没有成功,返回response是200:
{'status': '200', 'content-length': '1787', '-content-encoding': 'gzip', 'x-powered-by': 'Express', 'server': 'nginx/1.7.9', 'last-modified': 'Mon, 15 Sep 2014 03:03:08 GMT', 'connection': 'close', 'etag': 'W/"1787-1410750188000"', 'cache-control': 'public, max-age=0', 'date': 'Sat, 14 Feb 2015 05:14:50 GMT', 'content-type': 'text/html; charset=UTF-8'}
但是后台查看数据并没有更新,不知道是不是body那里没有写对呢?
官方文档里说:对于POST和PUT请求,请求的主体必须是 JSON 格式,而且 HTTP header 的 Content-Type 需要设置为 application/json
有人知道具体应该怎么操作吗?
|
|