Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Hello
I'd like to make an app that notifies event triggered by a service of event/subscripttion/service or something.
So I planned to use Firebase to satisfy the objective.
Arduino Yun - (REST call with curl) - Thingworx - (value exceeds limit, event triggered) - (_send event happened_) - Firebase --- Smartphone
But I can't found how Thingworx send REST httprequest to external service.
If not available, I'd like to know how to implement an app with notification feature.
Thank you.
Hi Hyeuntae
This is how to allow all REST calls through browser URL
Also the following cURL command can be used to send / update properties via a PUT request to the ThingWorx Server:
curl -X PUT <AUTHOPTION> -H "Accept: application/json" -H "Content-Type: application/json" -d '{"<PROPERTYNAME>":"<PROPERTYVALUE>"}' "http://<HOSTNAME>:<PORT>/Thingworx/Things/<THINGNAME>/Properties/*"
Where:
<AUTHOPTION> is replaced with authentication credential option (-u username:password), or App Key header option (-H "header")
Authenticate using username / password (Note: No quotes!):
-u <Username>:<password>
Authenticate using appKey (Note double quotes):
-H "appKey: <appKey>"
<PROPERTYNAME> is replaced with the name of the property to update
<PROPERTYVALUE> is replaced with the value of the property.
<HOSTNAME> is replaced with the hostname of the ThingWorx server
<PORT> is replaced with the port that the ThingWorx server is running on.
:<PORT> can be omitted from the URL if ThingWorx is running on a standard HTTP (80) or HTTPS (443) port.
<THINGNAME> is replaced with the name of the Thing to update.
For connections to an SSL server with a self-signed certificate, you may need to include the -k flag if the certificate is not trusted.
For useful diagnostic output on the status of the request and the response sent back to the cURL command, add the -v flag to the command.
Sample output:
> PUT /Thingworx/Things/PTC.OSLC.Configuration/Properties/* HTTP/1.1
> Authorization: Basic QWRtaW5pc3RyYXRvcjphZG1pbg==
> User-Agent: curl/7.35.0
> Host: 127.0.0.1:7000
> Accept: application/json
> Content-Type: application/json
> Content-Length: 20
>
} [data not shown]
* upload completely sent off: 20 out of 20 bytes
< HTTP/1.1 200 OK
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< X-FRAME-OPTIONS: SAMEORIGIN
< Set-Cookie: JSESSIONID=1B8C9D3D39410391C2A76BF860A34649; Path=/Thingworx/; Secure; HttpOnly
< Expires: 0
< Cache-Control: no-store, no-cache
< Cache-Control: post-check=0, pre-check=0
< Pragma: no-cache
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Date: Wed, 20 Apr 2016 14:04:02 GMT
<
100 20 0 0 100 20 0 31 --:--:-- --:--:-- --:--:-- 32{ [data not shown]
100 20 0 0 100 20 0 31 --:--:-- --:--:-- --:--:-- 31
* Connection #0 to host 127.0.0.1 left intact
I hope this helps.
Best Regards,
Amine