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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Upload file to ThingWorx cloud from REST URL

ss1
1-Visitor
1-Visitor

Upload file to ThingWorx cloud from REST URL

Hi Team,

Basically I have created a file upload widget (mashup) which uploads the file to my thingWorx cloud instance manually(click on browse->upload) and it was a success.

Now I wanted to automate the  activity from REST Client like postman.

If my URL is http://gexxxx.cloud.thingworx.com/Thingworx/FileRepositories/getFileUploadThing/- I tried to post the file ( with headers as appKey - "my application key")

In body selected binary - and browsed the file to upload and hit send in postman

I recieved the error response.

<html>

    <head>

        <title>Apache Tomcat/7.0.52 - Error report</title>

        <style>

            <!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}-->

        </style>

    </head>

    <body>

        <h1>HTTP Status 500 - Content type may not be null</h1>

        <HR size="1" noshade="noshade">

        <p>

            <b>type</b> Status report

        </p>

        <p>

            <b>message</b>

            <u>Content type may not be null</u>

        </p>

        <p>

            <b>description</b>

            <u>The server encountered an internal error that prevented it from fulfilling this request.</u>

        </p>

        <HR size="1" noshade="noshade">

        <h3>Apache Tomcat/7.0.52</h3>

    </body>

</html>

However I were able to successfully download the file from REST with GET method and later created a java application to download the file.

I am stuck with steps to upload file to cloud using rest.

Thanks,

Suraj.S

5 REPLIES 5
PaiChung
22-Sapphire I
(To:ss1)

The Thingworx intro Connectivity course covers this, I recommend people take this course to learn about this.

Could you point were this course is?

arunkumar1
12-Amethyst
(To:ss1)

In Postman, try adding File type in form-data.

ss1
1-Visitor
1-Visitor
(To:arunkumar1)

Hi Arun,

Thanks..But that does not seem to work too... POSTED , with headers as appKey(key) - value (application key) and Content-Type - application/xml

In body - selected Form-Data and browsed the xml file and hit the URL :

http://gexxxx.cloud.thingworx.com/Thingworx/FileRepositories/getFileUploadThing/

Recieved error :

   <h1>HTTP Status 405 - HTTP method POST is not supported by this URL</h1>

        <HR size="1" noshade="noshade">

Thanks,

Suraj.S

arunkumar1
12-Amethyst
(To:ss1)

Which version of Thingworx are you using? I believe older versions doesn't support POST.

For sending plain text data we could use method=POST in query parameter as:

     http://gexxxx.cloud.thingworx.com/Thingworx/FileRepositories/getFileUploadThing?method=POST

however for sending File, even I'm not sure.


Regards

Arunkumar D

Announcements


Top Tags