Hi Folks,
I have a requirement to download the files of Windchill objects into Thingworx repository. I am getting the Link of files inside Thingworx using Odata Connectors. I am able to generate the file in Repository but when I try to open the file getting error "Failed to load PDF document."
Below is the code I am using :
// result: JSON
let inputJson = Things["ptc-windchill-integration-connector"].downloadAsZip({
respondWithZip: false /* BOOLEAN {"dataShape":""} */,
$expand: undefined /* STRING {"dataShape":""} */,
objectId: <objectId>
});
// result: JSON
let csrf = Things["Thing.ODataConnector.ProdMgmt_TH"].GetCSRFToken({
$select: undefined /* STRING {"dataShape":""} */
});
item = inputJson.items[0];
let params = {
url: <file_url> /* STRING */ ,
headers: {
"CSRF_NONCE": <Nonce token>,
"Accept": "*/*",
"X-Requested-With": "XMLHttpRequest"
}
};
// result: BLOB
let binaryContent = Resources["ContentLoaderFunctions"].LoadBinary(params);
result = binaryContent;
let fullPath = "/test4/" + item.name;
Things["SupportRepository"].SaveBinary({
path: fullPath /* STRING */,
content: binaryContent /* BLOB */
});
What is wrong in my code to authenticate it while downloading it in Thingworx Repository.
Thanks in advance.
Regards,
VV