I am trying to use a rest API to download a file, it appears to work, but I dont actually have a file downloaded. I am assuming its because its going to memory, and not to my file system.
Below is the portion of code responsible. My URL is slightly edited when pasting it below, and my authToken is valid.
backup_url = "#{proto}://#{my_host}/applications/ws/migration/export?noaudit=#{include_audit}&includebackup=#{include_backup_zips}&authToken=#{my_token}"
resource = RestClient::Resource.new(
backup_url,
:timeout => nil,
:open_timeout => nil)
response = resource.get
if response.code == 200
puts "Backup Complete"
else
puts "Backup Failed"
abort("Response Code was not 200: Response Code #{response.code}")
end
Returns:
# => 200 OK | application/zip 222094570 bytes
Backup Complete
There is no file present though.
Thanks,
Well you actually have to write to the file yourself.
Pathname('backup.zip').write response.to_s
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With