Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hello,
I am new with ThingWorx and I am trying to update a property Thing on a Mashup with Postman.
(I just want to see a value change on my webpage).
To do this, I have:
- created a Thing "Ju_TestThing" (ThingTemplate : GenericThing) with a property "Ju_value" (Base type : TEXT), default value=10.
- created a Mashup "Ju_TestMashup"
- added a label on the Mashup and connected "Ju_value" to my label with "GetPropertyValues".
- added a "Auto Refresh" widget (interval : 2s)
In System / Subsystems / PlatformSubsystem / Configuration, I have checked "Allow Request Method Switch" and unchecked "Filter Content-Type".
When I click on "View Mashup", it opens a new window with URL like this:
Question : Is the end of the URL my appKey ?
In Postman:
- set PUT
- set URL : http://pp-XXXXXXXXXXlu.devportal.ptc.io/Thingworx/Things/Ju_TestThing/Properties/*
- add header "Content-Type" and "Accept" with value "application/json"
- add header "appKey" with value "112c786d-7cd1-4aa0-826b-db2d9b2324de"
- add body : {"Ju_value":30}
The result is "405 not allowed".
I have tested many others URLs, headers, body, ... each time the result is "405 not allowed".
I have read "REST API Overview and Example" but I still don't understand.
Thanks for your help.
Solved! Go to Solution.
Thanks for your help.
It's still not working on my side. My server is running but no result.
I'm glad to know that my request is good. I stop my tests for the moment.
Best regards
I am sorry you are having problems. A guide that addresses this use exactly is available here:
https://developer.thingworx.com/resources/guides/rest-api-how-guide/property-values-rest-api-how
Taking a look at your URL I see a couple of changes:
http://pp-XXXXXXXXXXlu.devportal.ptc.io/Thingworx/Things/Ju_TestThing/Properties/*
Be sure you are using https
I know it is duplicating information, but you must put the property name in both the url and the JSON body:
/Thingworx/Things/Ju_TestThing/Properties/Ju_value
{"Ju_value":"30"}
Since you are sending a string, you also might need to have quotes around the value
I have tried to duplicate information and add quotes around the value:
Example :http://pp-1802071305lu.devportal.ptc.io/Thingworx/Things/Ju_TestThing/Properties/Ju_value
With http, Postman returns me status 405.
With https, Postman returns me status 401.
I have tested with HTTPie like in the documentation.
Here the error :
http -v -j PUT http://pp-1802071305lu.devportal.ptc.io/Thingworx/Things/Ju_TestThing/Properties/Ju_value appKey==50e5cf70-4bcd-44a3-a00d-2dbfb53b82c1 Ju_value="31"
http: error: ConnectionError: HTTPConnectionPool(host='pp-1802071305lu.devportal.ptc.io', port=80): Max retries exceeded with url: /Thingworx/Things/Ju_TestThing/Properties/Ju_value?appKey=50e5cf70-4bcd-44a3-a00d-2dbfb53b82c1 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f16976e0358>: Failed to establish a new connection: [Errno -2] Name or service not known',)) while doing PUT request to URL: http://pp-1802071305lu.devportal.ptc.io/Thingworx/Things/Ju_TestThing/Properties/Ju_value?appKey=50e5cf70-4bcd-44a3-a00d-2dbfb53b82c1
I am looking on google about this error, but not really simple.
I continue my tests, I hope I will find the problem.
That long error is basically a 404 error, your test server is probably not running and you need to restart it by signing into developer.thingworx.com and click on the "server" icon.
I tested your HTTPie command against my server and it worked for me (after replacing your server URL and appKey with mine)
Thanks for your help.
It's still not working on my side. My server is running but no result.
I'm glad to know that my request is good. I stop my tests for the moment.
Best regards
Also make sure that the platform allows the calls, check platform subsystem configuration.
Thanks for your help, but as I said in my first post, I have already check platform subsystem configuration.