I've updated the app and unfortunately I'm still getting the 502 Bad Gateway error. I'm starting to think that the issue is with the sandbox itself so I tried a new playbook that would send URLs to be scanned. That neither confirmed nor denied my suspicions because the new playbook fails with a 415 media type unsupported error and I'm still confused.
Original Message:
Sent: Mon May 13, 2024 09:09 AM
From: Calvin Wynne
Subject: Sending an attachment to a sandbox
Hey Maria,
No worries. Let me know how it goes!
Regards,
------------------------------
Calvin Wynne
Original Message:
Sent: Mon May 13, 2024 08:32 AM
From: Maria Czapkowska
Subject: Sending an attachment to a sandbox
Hi Calvin,
Thank you for your detailed response. It turns out we're using an outdated version of the REST API app. Will have to upgrade it and check if this works.
------------------------------
Maria Czapkowska
Original Message:
Sent: Mon May 13, 2024 06:51 AM
From: Calvin Wynne
Subject: Sending an attachment to a sandbox
Hey Maria,
REST API app has built-in functionality that allows for directly sending attachments from an incident (I'll get to that in a bit).
Firstly could you tell me how exactly does the sandbox expect the attachment to be sent? What i mean by this is, different endpoints can expect attachments to be sent in different ways.
- Sometimes the endpoint can expect the file to be sent as a multipart/form-data
- Sometimes, binary encoded into the body of the message
To accommodate such varied requests, REST API app's built-in attachment handler must be configured properly.
Now, moving on to the REST API app. If you open up the sample playbook `CALL REST API (PB)` that's shipped with the application by default, you can find a detailed guide, instructing you on how to use the application. If you scroll down to the attachment section, you should find information on how to specify your attachments with a rest request.
Things to remember:
- Any file you intend to send, must be uploaded to the incident as an `attachment` or `file based artifact`. Only certain artifact types (e.g email-attachment) qualifies as a file based artifact
- Should you wish to send as request body, set:
- incident.id
- attachment_id (or) artifact_id
- send_file_as_body = True
- attachment_form_field_name = ''
- If you wish to send as multipart/form-data
- incident.id
- attachment_id (or) artifact_id
- send_file_as_body = False
- attachment_form_field_name = 'file' // or the correct form field name specified by your endpoint
- Finally, construct a proper regular rest request with appropriate attributes such as rest_url, rest_method, rest_header, rest_body
Note: The attachment handler will automatically add all the attachment related request-headers automatically. Although, other request headers must be specified by the user.
File based artifact example:

If for some reason, you don't find the sample playbook, i have attached it here
------------------------------
Calvin Wynne
Original Message:
Sent: Mon May 13, 2024 02:33 AM
From: Maria Czapkowska
Subject: Sending an attachment to a sandbox
I'm wondering if anyone has had experience with this. I want to be able to send an attachment from SOAR to a sandbox, there isn't an app made for the sandbox so I'm using REST API app. I can't figure out how to send the attachment though. I tried using the attachment id, filename, I changed it to base64 encoding I'm always getting a 502 bad gateway error.
I also tried sending the file path from the server using:
"""https://ouripadr/rest/orgs/201/incidents/{0}/attachments/{1}/contents""".format(incident.id, attachment.id)
which gets me 401 unauthorized, meaning I can't access the file. How would I get authorized? I can send a post request with my login details but I don't get any token to then pass on in the get request trying to grab the file.
Any advice on how to send an attachment would be appreciated
------------------------------
Maria Czapkowska
------------------------------