Look at the Henk's sample in FileImportHelper.java
Each Segment is Read from the file to the buffer.
You would need to re-factor the sample code to use pure HttpPut
// issue series of segment PUTs
for (int index = 1; filedata.available() > 0; index++) {
byte[] buffer = new byte[Math.min(buffer_size, filedata.available())];
filedata.read(buffer);
HttpPut request = new HttpPut(path + "?" + SEGMENT + "=" + String.valueOf(index));
request.setHeader(HttpHeaders.CONTENT_TYPE, contentType);
request.setHeader(affinity.getName(), affinity.getValue());
request.setEntity(new InputStreamEntity(new ByteArrayInputStream(buffer)));
executeHttpRequest(request, Integer.valueOf(202), null);
}
------------------------------
Andrei Istomine
Open to work - anything Cognos
https://www.linkedin.com/in/andreii/------------------------------
Original Message:
Sent: Wed August 21, 2024 10:11 AM
From: Puneet Bansal
Subject: Upload a file through REST API
Thanks @Andrei Istomine thanks for sharing this, its really helpful but i am using the Spring boot code. I am facing the issue while uploading the file. Could you please tell me what should the body of below type.
/files/import/segment/"+segament+"?index=-1"
------------------------------
Puneet Bansal
Original Message:
Sent: Mon August 19, 2024 06:13 PM
From: Andrei Istomine
Subject: Upload a file through REST API
You can check the Python sample out.
Sample python script to upload a file (csv, xls, xlsx) to Cognos Analytics 11.1.7 and above using the REST API.
------------------------------
Andrei Istomine
Open to work - anything Cognos
https://www.linkedin.com/in/andreii/
Original Message:
Sent: Mon August 19, 2024 10:30 AM
From: Puneet Bansal
Subject: Upload a file through REST API
@HENK CAZEMIER do you know the jar which we have to use in order to use the Java classes.
------------------------------
Puneet Bansal
Original Message:
Sent: Tue October 17, 2023 01:56 PM
From: HENK CAZEMIER
Subject: Upload a file through REST API
Hello Jiri,
I've attached a couple of files that should help to get you started. These files were part of the sdk distribution in an earlier release, but didn't make it into the more recent releases. (We will try to get that corrected).
Hopefully this will help you to be able to make progress.
------------------------------
Kind regards,
Henk Cazemier
Original Message:
Sent: Mon November 23, 2020 07:19 AM
From: Jiri Smrz
Subject: Upload a file through REST API
Hello,
I would like to use POST files/import Cognos REST API to upload an excel file from file system.
Unfortunately I did not figure out how to do that and I have not found any example how to fill fileimport JSON body. Has anyone managed to run this? I will appreciate any help!
Thank you!
------------------------------
Jiri Smrz
------------------------------
#CognosAnalyticswithWatson