当我调用下面的函数向我的端点发出AttributeError数据的post请求时,我得到了“JSON (‘strip’,)”
def makePostRequest(apiUrl, body):
try:
jsondata = json.dumps(body)
jsondataasbytes = jsondata.encode('utf-8') # needs to be bytes
len(jsondataasbytes)
req = urllib2.Request(apiUrl, jsondata, {'Content-Type': 'application/json',
'Content-Length': jsondataasbytes})
try:
response = urllib2.Request(req, jsondataasbytes)
response_data = response.read()
print (response_data)
except Exception as err:
print ("Error: %s", err)
except Exception as error:
print ("error in makePostRequest: ", error)https://stackoverflow.com/questions/44546209
复制相似问题