无法使用 api 将数据上传到 thingworx

Not able to upload the data on thingworx with api

尝试了很多方法在 thingworx 上上传数据(他们网站上给出的邮递员、httpie 等),但无法做到这一点。 请查看以下代码以将数据上传到 thingworx:

import requests
import json
app_key = 'xxxx'
url = 'http://pp-1804040542ze.devportal.ptc.io/Thingworx/Things/lmtech_thing/Properties/humidity'
prms = {'appKey': app_key}
hdrs = {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
}
data = {'humidiy': '20'}
text = json.dumps(data)
print 'data: ' + text
r = requests.put(url, params=prms, headers=hdrs, data=text)
print r.status_code

已成功创建事物和密钥。但它总是 return 404 错误。

也试过邮递员。以下是屏幕截图,如下所示:

以下代码对我有用:-)

import requests  # Import requests library to send requests to Thingworx

url = 'http://52.199.28.120:8080/Thingworx/Things/work_thing/Properties/temp'
# temp is one of my property name
value = 12    # Upload 12 on Thingworx

headers = {
    'Content-Type': 'application/json',
    'appkey': 'xxxxxxxxxxxxxxxxxxxxxx',
    'Accept': 'application/json',
    'x-thingworx-session': 'true',
    'Cache-Control': 'no-cache',
}

data = {"temp": value}   # JSON data to upload on Thingworx

response = requests.put(url, headers=headers, json=data)
# Note that we have to send put request

print 'Response Code:', response.status_code
# If 200 then data has been uploaded successfully
print 'Response Content:', response.content