How to upload a file through REST from authenticated server?


I’m trying to upload a file through REST but the API only allows for a ‘public’ url from which the file is uploaded - or so it seems.

Swagger documentation:

location	A URL the uploaded file can be downloaded with

So, when I use a public url like this will work fine.

However, when I have a url on an authenticated server in which I need to supply an Authorization header to access the file (another REST interface actually), I’m stuck it seems.

Is there any way to get this file uploaded/added through REST?


I don’t fully understand your question. If the questions is

Is there any way to get this file uploaded/added through REST?

then it is described here: CUBA REST API

You’ll have to pass the token in the header or as an url parameter, e.g.


If your question is not about that then please describe it in more details.

Hi Max,

Thank you for replying and looking into this.

Thing is, the file is located at a remote server (not a Cuba application) that requires to provide an Authorization header in the request to retrieve the file.

In my scenario, I’m able to a number of REST calls but I have no intermediate storage or something to first retrieve the file and then upload it through REST into our own Cuba application.

So basically, I want to provide a link in the Location header for the REST call to upload a file: Swagger UI AND have control over the Authorization header when this REST call and the retrieval of the file is actually executed by the Cuba application.

I’ve tried to illustrate the problem in the scenario below:

I hope this helps to clarify my issue.

Thanks for any help.


I think you misunderstand the Location header. It a response, not request header. After you make the POST request that uploads the file to CUBA app, the Location header in the response will contain a URL where just uploaded file can be download from the CUBA application.

As a solution of your problem, you’ll have to create custom REST controller that accepts required parameters (URL to the file in external server, tokens, etc.) and then does its ork - downloads the file by passed URL, saves it to CUBA app, etc.

1 Like

Ah, yes - you are right, I thought it was the request parameter but instead this is a response parameter.

Thanks for explaining and your suggested solution.