Привет, я новичок в python и ниже мой код, который вызывает REST API:
api_url = 'https://gateway.eu1-int.myproject.io/api/iottimeseries/v3/timeseries/1234/propertyname'
payload =[{
"_time": "2017-12-30T09:54:28.502Z",
"FLWheel_qc": 1,
"FRWheel_qc": 13,
"RLWheel_qc": 55,
"RRWheel_qc": 6
}]
headers = {'Content-Type': 'application/json'}
http_proxy = 'http://' + rest_client_config.proxy_host + ':' + rest_client_config.proxy_port
proxy_dict = {
"https": http_proxy
}
json_payload = json.dumps(payload)
r = requests.put(api_url, json=payload, headers=headers, proxies=proxy_dict)
json_data = json.loads(r.text)
Я пробовал другую комбинацию в запросах.
json_payload = json.dumps(payload)
r = requests.put(api_url, data=json_payload, headers=headers, proxies=proxy_dict)
или
r = requests.put(api_url, data=payload, headers=headers, proxies=proxy_dict)
Остальные API разработаны с использованием весенней загрузки, я получаю следующую ошибку:
{'timestamp': '2018-11-03T12:36:09.585+0000', 'status': 400, 'error': 'Bad Request', 'exception': 'org.springframework.http.converter.HttpMessageNotReadableException', 'message': 'JSON parse error: Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token\n at [Source: java.io.PushbackInputStream@664d6d8c; line: 1, column: 1]', 'path': 'api/iottimeseries/v3/timeseries/1234/propertyname'}
Я застрял в этом с давних пор. Я перепробовал все возможные решения, которые нашел. Однако точно такой же запрос работает от почтальона. Пожалуйста, дайте мне знать, если я что-то упустил.