Skip to main content
12-Amethyst
September 24, 2021
Solved

How can i use webservice to create a folder in a thingworx repository?

  • September 24, 2021
  • 1 reply
  • 1387 views

Hi ,

 

I want to create a folder in a thingworx repository to be able to upload a file in it.

I know how to upload a file, for example:

curl -v -H "X-XSRF-TOKEN: TWX-XSRF-TOKEN-VALUE" -H "AppKey: $APPKEY" \
-F "upload-repository=MyRepository" \
-F "upload-submit=Upload" \
-F "file=@myFile.tar.gz;type=application/x-zip-compressed" "$TWXURL/FileRepositoryUploader" \
-m 60 -f

 

I want to create a subfolder by the same way?

 

Thanks for your help.

Best answer by cbaurand

In fact, upload creates automatically a folder if not exist:

curl -v -H "X-XSRF-TOKEN: TWX-XSRF-TOKEN-VALUE" -H "AppKey: $APPKEY" \
-F "upload-repository=MyRepository" \

-F "upload-path=MyNewFolder \

-F "upload-submit=Upload" \
-F "file=@myFile.tar.gz;type=application/x-zip-compressed" "$TWXURL/FileRepositoryUploader" \
-m 60 -f

 

This solution works fine!

1 reply

17-Peridot
September 24, 2021

The FileRepository ThingTemplate has a service called CreateFolder that you can call with the REST API.  The only input to it is the path.

 

Hope that helps!

--Nick

cbaurand12-AmethystAuthorAnswer
12-Amethyst
September 24, 2021

In fact, upload creates automatically a folder if not exist:

curl -v -H "X-XSRF-TOKEN: TWX-XSRF-TOKEN-VALUE" -H "AppKey: $APPKEY" \
-F "upload-repository=MyRepository" \

-F "upload-path=MyNewFolder \

-F "upload-submit=Upload" \
-F "file=@myFile.tar.gz;type=application/x-zip-compressed" "$TWXURL/FileRepositoryUploader" \
-m 60 -f

 

This solution works fine!