Downloading Attachment (File) from REST API JIRA on-prem to local drive

Hi, I have a problem downloading the attachment (file) from the REST API JIRA on-prem response:
Example url:{id}/{file_name}

This is my CSharp (C #) code:

var client = new RestSharp.RestClient("");
client.Timeout = -1;
var request = new RestSharp.RestRequest(Method.GET);
request.AddHeader("Authorization", String.Format("Basic {0}", Secret));
response = client.Execute(request);
fileBytes = client.DownloadData(request);

I used the Invoke Method activity to write a byte array (byte[]) to a file. The file writes, but instead of 1.11MB, it only has 4KB.

When I perform the same query using cURL in Postman:

curl -L -O -k -u 'user:pass' -X GET

I have the option to save the attachment via the Save Response> Save to a file option:


File saved by Postman:

File saved by Invoke Method:

Both IRestResponse.RawBytes As Byte [] and fileBytes As Byte [] = client.DownloadData(request) have the same number of bytes:

What’s the problem?
Why is Postman able to save the file and my code not?

@ppr, @Yoichi, @loginerror, @Cristian_Negulescu

Hello Adrian,
In this video I download documents from jira via rest api

Cristian Negulescu

Also on this video at time 6:05 I show how I download file in code
UiPath download and upload files to any website via (HTTP request) - YouTube

1 Like


StausCode shows Unauthorized. So probably there is some matter with format of ID/Password.

The following might help you.


thanks for reply @Yoichi and @Cristian_Negulescu.

Working RestSharp code for REST API JIRA [GET] attachment:

var client = new RestSharp.RestClient(URL);
client.Authenticator = new 
var request = new RestSharp.RestRequest(Method.GET);
response = client.Execute(request);
1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.