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

ThingWorx Navigate is now Windchill Navigate Learn More

Translate the entire conversation x

Help required to send files from Thingworx to Azure Blob Storage using REST API

Janaki.Raman
11-Garnet

Help required to send files from Thingworx to Azure Blob Storage using REST API

Hello Team,

 

Am trying to upload some pdf files from thingworx repository to azure blob storage using REST API,

 

Could you please share any sample code available for the same?

 

below is what am trying

 

var params = {
url: "https://<AccountName>.blob.core.windows.net/<container>/<folder>?<sasToken>",
headers: {
"x-ms-blob-type": "BlockBlob"
},
content: fileContent, // Ensure this is raw file content
contentType: "application/octet-stream",
timeout: 60000 // 60 seconds
};

// Use ThingWorx HTTP POST/PUT
var result = Resources["ContentLoaderFunctions"].PutText(params);

 

 

 

Not getting any result or error, please help

ACCEPTED SOLUTION

Accepted Solutions

why create a new thread? -> https://community.ptc.com/t5/ThingWorx-Developers/File-upload-to-azure-blob-storage/m-p/1036431/highlight/true#M70648 

I would try the request via PostMan tool first, and then try with TWX. Azure also has a sample request where they use AuthorizationHeader (not sure if sasToken works like you have) https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob?tabs=microsoft-entra-id#sample-request 

View solution in original post

4 REPLIES 4

why create a new thread? -> https://community.ptc.com/t5/ThingWorx-Developers/File-upload-to-azure-blob-storage/m-p/1036431/highlight/true#M70648 

I would try the request via PostMan tool first, and then try with TWX. Azure also has a sample request where they use AuthorizationHeader (not sure if sasToken works like you have) https://learn.microsoft.com/en-us/rest/api/storageservices/put-blob?tabs=microsoft-entra-id#sample-request 

Hello @Janaki.Raman ,
Not quite sure what your goal is with the transfer.
Have you considered "SaveBinary"  -  CS212085 - How to use blob data to save a physical file as it is to Thingworx server


CS320797 - Connecting Azure Blob Storage to ThingWorx Platform

Regards,

Pehowe

 

params = {
url: "https://<StorageAccount>.blob.core.windows.net/<container>/<filename>?<sasToken>,
headers: {
"x-ms-blob-type": "BlockBlob",
"Content-Type": "text/plain"
},
content: fileContent, // Ensure this is raw file content
timeout: 60000
};
 
result = Resources["ContentLoaderFunctions"].PutBinary(params);

Hello @Janaki.Raman ,

Here is some code. This is a ThingWorx Service which  is sending a file to another ThingWorx environment:
 

Let me know if this is helpful. I will look to see if I have a save Binary or other operations

Regards

Pehowe

Announcements


Top Tags