Need to create the scripted rest api to capture Attachment
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 10:41 AM
Hi All,
I have created a scripted API through which third-party tool creates an incident in my instance using json. Now they are sending attachments with the JSON. I need to attach the attachment in my incident.
Here the below sample Json which I received from the third party tool. In this json, it is not showing the file type,name etc. Only timestamp and attachment_id. Not sure how to configure to capture the attachment. Can someone please help on this.
{
"Number" : "CS0134435",
"Short_description" : "Test Short Description",
"Description" : "Test Description",
"Priority" : "Low",
"Closed" : "",
"Closed_notes" : "",
"Comments" : "",
"Attachments" : [ {
"Timestamp" : "2024-05-13T12:42:13.000Z",
"Attachment_id" : "f2707b0a4e10eaf4ec6fe54bcb5d"
} ]
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 10:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 09:43 PM
what information are they sending for attachment?
you should get file name, file type, base64 data of that file. then only you can create file
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 11:32 PM
Hi Ankur,
Thanks for the quick response. As I mentioned above, I am getting this below JSON when third-party applications consume the Scripted REST API. The attachment parameter only has a timestamp and attachment_id.
{
"Number" : "CS0134435",
"Short_description" : "Test Short Description",
"Description" : "Test Description",
"Priority" : "Low",
"Closed" : "",
"Closed_notes" : "",
"Comments" : "",
"Attachments" : [ {
"Timestamp" : "2024-05-13T12:42:13.000Z",
"Attachment_id" : "f2707b0a4e10eaf4ec6fe54bcb5d"
} ]
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 03:49 AM
Hi Ankur,
Third-party applications are sending the JOSN with the File name and File content. Can you please provide the generic cond to create an attachment for this JSON below?
{
"Filename" : "test_file.txt",
"File_content" : "mZdfdfdfsf1bCB3YXkgdG8gaGfgfVscCB5b3U"
}