Python requests 库发送 body 只有一个 list 的请求的写法
[300004167],发送的 body 是这样的格式,对,没有 key,只有 value,查过确实也是正确的 json 格式,用 postman 发送可以正常返回,但是用 python 的 requests 库,试了好几种写法都是报错:
各位朋友有没有好的办法解决,谢谢!
—-self.DeviceManage.send_post(url, json.dumps([300004167]), header)
报错:json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
—-self.DeviceManage.send_post(url, [str(300004167)], header)
报错:ValueError: too many values to unpack (expected 2)
—-self.DeviceManage.send_post(url, numpy.array([300004167]), header) #试图转数组
报错:json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)