Discussions

Ask a Question
Back to All

Get an Image is broken

I have followed instructions to get an Image


  1. First get the attachment UUID from the /attachment endpoint
  2. Then make a GET request to: https://api.servicem8.com/api_1.0/attachment/{uuid}.file
  3. Follow the redirect to download the image

But there is no redirect

I can only see a 200 json response, with no Location header, and no redirect. I'm using the suggested library for node, node package "@api/servicem8". I have also tried this in other libraries, and in Postman to verify this is not a lib issue, since I know for sure Postman always follows redirects.

Please advise on how to get the jpg Attachments out Otherwise I may need to reverse engineer your private api, which is not ideal for either of us.

This is the console trace output of the @api/servicem8:

console.log("headers:", attachment.headers);
console.log("url:", attachment.res.url);
console.log("status:", attachment.res.status);
console.log("redirected:", attachment.res.redirected);
console.log("data:", attachment.data);
headers: {
  'alt-svc': 'h3=":443"; ma=86400',
  'cache-control': 'max-age=0',
  'connection': 'keep-alive',
  'content-encoding': 'gzip',
  'content-type': 'application/json',
  'date': 'Fri, 20 Jun 2025 10:38:07 GMT',
  'expires': 'Fri, 20 Jun 2025 10:38:07 GMT',
  'server': 'Apache',
  'strict-transport-security': 'max-age=63072000; includeSubDomains',
  'transfer-encoding': 'chunked',
  'via': '1.1 a59cacde45227666db5b17829b32dd94.cloudfront.net (CloudFront)',
  'x-amz-cf-id': 'dV44ydbARS7aucQIl1l4oPdrLKiZhOAgwaVjNMZCQmSyqYdZJKpyaA==',
  'x-amz-cf-pop': 'LHR62-C4',
  'x-cache': 'Miss from cloudfront',
  'x-frame-options': 'SAMEORIGIN',
  'x-platform-date-utc': '2025-06-20 10:38:07'
}
url: https://api.servicem8.com/api_1.0/attachment/8ca64263-0a3b-4de5-a08e-1d21c8b60dfb.json
status: 200
redirected: false
data: {
  uuid: '8ca64263-0a3b-4de5-a08e-1d21c8b60dfb',
  edit_date: '2021-01-01 01:01:01',
  active: 1,
  attachment_name: 'sample_photo_3.jpeg',
  file_type: '.jpg',
  photo_width: '4032',
  photo_height: '3024',
  attachment_source: '',
  lng: 0,
  lat: 0,
  tags: '',
  extracted_info: '',
  is_favourite: '0',
  class_name: '',
  metadata: false,
  signature_data: false,
  created_by_staff_uuid: '***',
  timestamp: '2020-01-01 01:01:01',
  related_object: 'job',
  related_object_uuid: '***'
}