Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Hello eveyone;
I recently discovered that in ThingWorx 8 , adding appKey to url for authentication has ben removed for security reasons.
I cant find working HTTP Requests examples which includes necessary headers with proper syntax.
I am using NodeMCU with MicroPython Flash. I can successfully make HTTP requests to any REST testing site. eg. https://httpbin.org/.
I also test my Url in Postman. which it also work properly.
http://<server>/Thingworx/Things/NodemcuTest/Properties/input
Here is my code.
Note : I use urequests library as requests.
url = 'http://<server>/Thingworx/Things/NodemcuTest/Properties/input'
headers = {'appkey': 'xxxx-xxxx-xxx-xxxx-xxxx-xxx'
'Accept': 'application/json'}
getreq = requests.get(url, headers=headers).json()
s = getreq["rows"][0]["cont"]
print(s)
I hope i made myself clear about the issue.
Thank you.
Murat Can
Hi Murat,
The application key can be passed in as an http header called "appKey" (caplital K).
Hopefully that helps!
~James
Hi James;
I switch to using Arduino IDE to programming nodeMCU and it worked...only works on my local Thingworx Installition.
http://<host>/Thingworx/Things/testThing/Properties/testProp?method=PUT&appKey=<appkey>&value=1
This syntax must be true -it works on my local Thingworx 8.0.2- but its not working on neither Postman nor our servers which installed Thingworx 8.0.2 and 7.4.
Hi Murat,
From a security standpoint, its preferable to use http headers over URL parameters. For example
Post to http://localhost:8080/Thingworx/Things/JamesTestThing/Services/HelloWorld
Headers:
Content-Type: application/json
Accept: Application/json
appKey: <someAppKeyAsAVeryLongString>
This returns a result for me
{
"dataShape": {
"fieldDefinitions": {
"result": {
"name": "result",
"description": "",
"baseType": "STRING",
"ordinal": 0,
"aspects": {}
}
}
},
"rows": [
{
"result": "Hello World"
}
]
}
Hi,
I tried your suggestions and is making a GET call to a thing property from Postman.
I have tried sending the appKey in url and it gave me a 404 not found error.
Next, i tried sending it as Header and still I am getting a 404. please see the screen shot attached. Any help would be appreciated.
Thanks
Do you have this myhouse thing for which you are fetching watts property.
Hi,
I was able to solve this issue
This is with reference to the article
https://www.ptc.com/en/support/article?n=CS264349
https://community.thingworx.com/thread/43129
Will the appkey param also supported in the Request header in the 7-4-15 ThingWorx version ?