Download REST API Attachment File of the Response

We’re using HTTP Request to call the REST API.

The REST API, POST, has a response with an attachment file.

How can we download this file and save it.

We tried to use ResourcePath property, but it seems it stores all the response of the API, not the attached file itself.

Thanks in Advance…

i guess it depends on your request, which is the response format?

The response format is multipart/mixed and the attachment is csv file.

and it is really a POST to receive a file??

Actually, It POST around 200 transactions. The received file is summary of these transactions including the status of each transaction.
For example, these transactions are invoices, we create the invoices, at tax then validate them.

did you try like this?

Ya, I tried it. It maps to the property of ResourcePath.
All the response gets loaded at the specific path, not only the attachment file.

For example:
------=_Part_124_1858720322.1576525050413\r\nContent-Type: application/json\r\n\r\n{ "invoicesCount" : 24, "invoicesFailed" : 0, "invoicesSucceeded" : 24}\r\n------=_Part_124_1858720322.1576525050413\r\nContent-Type: text/csv\r\nContent-Disposition: form-data; name="OracleCreatedInvoices.csv"; filename="OracleCreatedInvoices.csv";
BUSINESS_UNIT,INVOICE_NUMBER,AMOUNT,CREATION_STATUS,VALIDATION_STATUS
TEST57-INT-ANN-SEP-19-P013401,42517.88,SUCCESS,Needs revalidation\nESEC - BU2,TEST57-DOM-BUS-SEP-19-P013401,1424.85,SUCCESS,Validated\nESEC - BU2,TEST57-DOM-EXT-SEP-19-P013401,413.7,SUCCESS,Validated\n\r\n------=_Part_124_1858720322.1576525050413–\r\n",
“level”: “Information”,
“logType”: “User”,
“timeStamp”: “22:39:02”,
“processVersion”: “1.0.0”,
“jobId”: “a9f9bdaf-d4b7-4925-8ab3-6cc3d31b9033”,
“machineId”: 0
}

this response do not seem to have the file as binary, but its contents are inside it, did you parse this response as json and examine the object to see the easiest way to get the content of the csv.

I can try parsing it to get the json response and csv contents separately.
But the point, when I try the API from SoapUI or Postman, I’m able to get the contents of json and the attached file separately.

i would try it for you using the uipath activity but i dont have a service to test the results…

No worries bcorrea, appreciating your responses and suggestions.
I’ll parse the response to get the needed data.
Many thanks…

1 Like

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