cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Update Image property via REST request

SOLVED
Highlighted
Alexandrite

Update Image property via REST request

Hello everyone,

 

I have an entity with an image property which I would like to update from my edge device (note that I am working with the java sdk). Since it is actually a live stream from a camera I will update this image frequently (something like 2 or more per second). 

 

It was suggested to me to use the fileTransferSubsystem for that, but I would prefer doing that with a PUT Rest request. Can anyone explain how to exactly send images like this? I am using postman for testing and using the following headers and parameters:

 

address: https://serverIP:Port/Thingworx/Things/Camera/Properties/CurrentImage

accept and Content-type: application/json

appKey: theAppkey

 

body: {"CurrentImage": binaryEncodedImage}

 

I get a 200 OK response but the image is not updated. I think my image might be wrongly decoded so my main question is, which representation of the image should I put in the json body?

 

I get the images through a GET request from another server so in my java program the image can either be represented as a byte[] array, an inputStream or a simple Image object. For postman I also tried it with a .jpg as a binary.

 

I am thankfull for any suggestions.

 

Kind Regards,

Dominik

 

Edit: I already changed the configuration of the PlatformSubsystem to allow Request Method Switch and disabled filter content type

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Update Image property via REST request

The image should be base64 format. Here is a working example: https://community.ptc.com/t5/ThingWorx-Developers/Uploading-an-image-through-REST-api-to-an-image-pr...

 

Considering your use case with live stream from a camera, take a look at the video streaming widget: https://community.ptc.com/t5/ThingWorx-Developers/How-to-display-a-live-vedio-stream-on-Thingworx-ma...

 

Best regards,

Cristina

 

2 REPLIES 2

Re: Update Image property via REST request

The image should be base64 format. Here is a working example: https://community.ptc.com/t5/ThingWorx-Developers/Uploading-an-image-through-REST-api-to-an-image-pr...

 

Considering your use case with live stream from a camera, take a look at the video streaming widget: https://community.ptc.com/t5/ThingWorx-Developers/How-to-display-a-live-vedio-stream-on-Thingworx-ma...

 

Best regards,

Cristina

 

Re: Update Image property via REST request

Thank you, I wasn't converting byteArray to base64 String