Send API Multipart attachment to thirdparty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2024 03:34 AM
Hello,
I'am trying to send a API multipart attachment by business rule. I would like to do that without MID server but I have no idea how to do that.
Any idea ?
Thanks for your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2024 08:28 AM
Hello,
Thank you for your answer.
I found my way creating Action and flow in flow designer. It works well.
Cheers,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 01:51 AM
That's great to hear! If you have any questions or need further assistance with ServiceNow's Flow Designer or any other aspect of ServiceNow, feel free to ask.
nowKB.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2024 02:16 AM
To send a multipart attachment to a third-party system from ServiceNow, you can use the RESTMessageV2 API. Here are the steps:
1. Create a new REST Message in ServiceNow.
- Navigate to System Web Services > Outbound > REST Message.
- Click on New to create a new REST Message.
- Fill in the necessary details like Name, Endpoint, HTTP Method etc.
2. Add HTTP Headers if required by the third-party system.
3. Create a new function in a Script Include or a Business Rule to send the attachment.
- Use the GlideSysAttachment API to get the attachment data.
- Use the RESTMessageV2 API to send the attachment data.
Here is a sample code:
javascript
var attachment = new GlideSysAttachment();
var attachmentGR = attachment.getAttachmentRecord('sys_id_of_attachment');
var restMessage = new sn_ws.RESTMessageV2('rest_message_record', 'http_method');
restMessage.setRequestHeader("Content-Type", "multipart/form-data");
restMessage.setRequestBodyFromAttachment(attachmentGR);
var response = restMessage.execute();
4. Check the response from the third-party system.
- Use the RESTResponseV2 API to get the response data.
Here is a sample code:
javascript
var statusCode = response.getStatusCode();
var responseBody = response.getBody();
5. Handle the response based on your requirements.
Please note that the 'sys_id_of_attachment' should be replaced with the actual sys_id of the attachment you want to send. The 'rest_message_record' and 'http_method' should be replaced with the actual REST Message record and HTTP method you want to use.
nowKB.com
For a good and optimistic result, and solving ServiceNow-related issues please visit this website.https://nowkb.com/home