import json
import requests
import pprint
from datetime import datetime
url = 'url'
cursor = context.cursor()
cursor.execute('SELECT * from table')
for a in cursor.fetchall():
urlpost = url + '/'+'Id'+'/data'
data = { "Id": str(a[0]),
"Name": "null",
"Type": str(a[4])
}
data_json = json.dumps(data)
headers = {'Content-type': 'application/json'}
response = requests.post(urlpost, data=data_json, headers=headers)
pprint.pprint(response.json())
我试图将表中的数据放入API。但是出现错误“值错误:无法解码JSON对象”。我不知道缺少什么!