【发布时间】:2016-02-22 17:04:38
【问题描述】:
我正在尝试使用 Python 将一些数据加载到 ML。这可以正常工作,但在 ML 中类型设置为“T”而不是“J”。 我想解决这个问题。标题设置似乎只是为了展示所以我该怎么做?
# Sending data
data = {'meting': '477', 'bericht': '473', 'plant': '01'}
url = 'http://server:8000/v1/documents?database=thijsPlantjes&extension=json'
headers = {'Content-Type': 'application/json'}
r = requests.post(url, json = json.dumps(data), auth=HTTPDigestAuth('plantje', 'password'), headers = headers)
【问题讨论】:
-
json关键字参数的全部意义在于它为您执行 JSON 序列化,包括将Content-Type标头设置为application/json。
标签: python json python-requests marklogic