Binary format data push to content server API (api/v1/nodes) OTCS version 24.3

Hi All ,
I am using web report rest client for getting the data downloaded from third party application.
Data is getting stored in below variable sample code:-
@method:GET
@secure:true
@header:[ll_reptag_!header /]
@output:JSON:binaryfile /]
My file is stored in variable names as binaryfile. My use case is i want to push this file to content server for which i have generated otcsticket using WR rest client and now i am calling the API.
https://servername/cs/cs/api/v1/nodes Post method
and i am setting the header with otcsticket. To create a document 4 params are required
parm 1) type =144
parm 2) name=filename
parm 3) parent_id=120871
parm 4) file=""
I cant upload the direct binary file in 4 parameter.
Any way to solve this issue ?
Thanks
Nitesh
Comments
-
Reach out to OT support. If they say Pay Professional Services, do that or look at how to do this with some custom coding. All you have to do is put the content as a File and use the File Upload method. I know you are trying to avoid that and be efficient but I haven't seen such examples
0 -
Thanks @appuq , but i found the solution using Blob
0 -
Glad to help community :-
Use below AJAX code in your web report to get the data downloaded in your browser from binary to pdf format:-
.then(response => {
console.log("Response Status:", response); // Log HTTP status
console.log("Response Headers:", response.headers); // Log headers
if (!response.ok) {
throw new Error(HTTP error! Status: ${response.status}
);}
return response.blob();
})
.then(blob => {
console.log("Blob Data:", blob); // Log the blob data
let link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "document.pdf"; // Adjust the file name if needed
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
console.log(link);
})
.catch(error => console.error("Error downloading file:", error));
</script>
Thanks
Nitesh2
Categories
- All Categories
- 124 Developer Announcements
- 54 Articles
- 156 General Questions
- 155 Thrust Services
- 56 Developer Hackathon
- 38 Thrust Studio
- 20.6K Analytics
- 4.2K AppWorks
- 9.1K Extended ECM
- 920 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 35 eDOCS
- 195 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 11 XM Fax
- Follow Categories