Sending Attachments from ServiceNow to Azure DevOps through REST API's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 09:50 AM
Hi All ,
Can you please let me know how we can send attachments(when created and or updated) from ServiceNow to Azure DevOps through API .
Any code which can be written in business rule/script include would help
Thanks In Advance
Prashanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2023 10:03 AM
Create a business rule on attachment table and can have condition depending on your use case.
You can use below script as sample to send attachment. Make sure to change your request header as per your Azure API shared with you.
var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('sys_id', current.table_sys_id);
incidentGR.query();
if (incidentGR.next()) {
if (incidentGR.u_case_id != '') {
try {
var r = new sn_ws.RESTMessageV2('SOCIntegrationTask', 'Upload File');
r.setRequestHeader('Appian-Document-Name', current.file_name);
r.setQueryParameter('taskid', incidentGR.u_task_id);
r.setQueryParameter('application', incidentGR.u_application);
r.setRequestBodyFromAttachment(current.sys_id);
var response = r.execute();
var request = r.getRequestHeader();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
} catch (ex) {
var message = ex.message;
}
}
}
Please Mark it as correct or helpful, if it resolves your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 03:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2023 05:41 PM
Please check out attachment API
https://developer.servicenow.com/dev.do#!/reference/api/rome/rest/c_AttachmentAPI
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2023 04:25 AM
Hi Prashanth
To send attachments through the API, you can utilize the ADO REST API's Create Attachment or Update Attachment endpoints. Please prepare the request to ADO API: Build the HTTP request to the ADO API endpoint, including the necessary headers and authentication information. Ensure that you include the appropriate API version and project-specific details and convert the attachment to base64. Include the attachment data in the API request and then finally send the API request.
While developing this integration, you may encounter complexities or specific requirements that can be addressed by using an integration platform like Exalate. I have been using it for a year and it works really well for use-cases like this.