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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Can we Upload Files from REST API into Thingworx Repository?

koushal
12-Amethyst

Can we Upload Files from REST API into Thingworx Repository?

Hi,

 

Can we upload images from REST API or Postman into Thingworx Repository.

I am looking to upload files from Postman. Is thingworx services accept the files ?

Please let me know if it is possible.  

1 ACCEPTED SOLUTION

Accepted Solutions
slangley
23-Emerald II
(To:koushal)

Hi @koushal.

 

Within the context of your original question, yes, the image must be converted.  The sample code in the article initially provided, handles this conversion.

 

However, there are other options available that would not require the Base64 conversion.  For example, you could use the File Transfer Subsystem to transfer files.  Another option would be to use the File Upload widget on a mashup.

 

Please let us know if you have further questions.

 

Regards.

 

--Sharon

View solution in original post

9 REPLIES 9
slangley
23-Emerald II
(To:koushal)

Hi @koushal.

 

Here is an article that may help to answer your question.  Please let us know if you have additional questions.

 

Regards.

 

--Sharon

koushal
12-Amethyst
(To:slangley)

Hi Slangley,

 

I have checked the article. I want to use SaveImage Service but when I am calling from Postman I am getting an Error :No Binary Content specified. PFB the screenshot of Postman call.

I am using Content-Type as multipart/form-data in Headers.

slangley
23-Emerald II
(To:slangley)

Hi @koushal.

 

What happens when you select the "binary" option instead of the default of "form-data"?

 

Have you checked the ThingWorx logs located under \ThingworxStorage\logs for any additional information on the failure?

 

Regards.

 

--Sharon

koushal
12-Amethyst
(To:slangley)

Hi Slangley,

 

I have checked the thingworx logs too but the same message "No  binary conent specified" was logged into Script and Script Error Log.

Also, I have tried with Binary option but I got the same result.

 

 

koushal
12-Amethyst
(To:koushal)

HI ALL,

 

 

Can someone help me on this ?

slangley
23-Emerald II
(To:koushal)

Hi @koushal.

 

You will need to use Base64 encoding on the image file.  You can find an encoder/decoder online.

 

Please give this a try and let us know if you still have issues.

 

Regards.

 

--Sharon

koushal
12-Amethyst
(To:slangley)

hi,

 

I am able to save the files into Thingworx Repository if I convert the files into base64 encoding.

But I just want to know that If i am not converting the files into base64 I will not be able to save. Is that true?

In thingworx, we cannot upload the files into File Repository without converting into Base64.

Is it correct? please let me know    

slangley
23-Emerald II
(To:koushal)

Hi @koushal.

 

Within the context of your original question, yes, the image must be converted.  The sample code in the article initially provided, handles this conversion.

 

However, there are other options available that would not require the Base64 conversion.  For example, you could use the File Transfer Subsystem to transfer files.  Another option would be to use the File Upload widget on a mashup.

 

Please let us know if you have further questions.

 

Regards.

 

--Sharon

koushal
12-Amethyst
(To:slangley)

Hi ,

 

 

Thanks  for your valuable input.

Top Tags