PUT方法使用python3和urbllib - headers

时间:2018-06-08 22:35:08

标签: python json python-3.x put

所以我试图从这个json接收数据。我在任何链接上使用POST,GET但我正在尝试阅读的链接。它需要[PUT]。所以我想知道我是通过urllib正确调用这个url还是我错过了什么?

Request
{"DataType":"Word","Params":["1234"], "ID":"22"}

Response {
 JSON DATA IN HERE
}

我觉得我正在做PUT方法调用错误,因为它包含在Request {}中。

import urllib.request, json
from pprint import pprint
header = {"DataType":"Word","Params":"[1234"]", "ID":"22"}
req = urllib.request.Request(url = "website/api/json.service", headers = 
heaer, method = 'PUT')
with urllib.request.urlopen(req) as url:
    data = json.loads(url.read(), decode())
    pprint(data)

我可以打印json数据,只要它不是PUT。一旦我得到一个带有以下JSON模板的网站,我就会收到内部错误500.所以我认为这是我的标题。

先谢谢你了!

0 个答案:

没有答案