How to save file from the HTTP response?

aiexaiex Member Posts: 2
I have a codeunit which should send out an HTTP request for getting file (pdf or jpg) from web server and save the file to the certain path.
I have searched this forum, and didn't find suitable answer.

aut_Http is automation server 'Microsoft XML, v5.0'.XMLHTTP
...
IF ISCLEAR(aut_Http) THEN
CREATE(aut_Http);
aut_Http.open('GET', txtURL, FALSE);
aut_Http.setRequestHeader('Content-Type', 'application/pdf');
aut_Http.send;

As I understand the file content is in the aut_Http.responseBody.
How I can get file from the response and save the file?

For XML files I can use .DOMDocument load and save. In case the file type is pdf or jpg, what is the right automation server to use?

Comments

Sign In or Register to comment.