How to create an incident along with adding an attachment via Rest API post call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 04:48 AM
Hi Team,
Team,
I wrote a scripted API and trying to post the data from rest API explored, but i dont see provision to add attachement data from explorer to test the case.
May i know how to achive this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 05:37 AM
Hello @srinivasrao ,
I believe you should consider using Attachment API along-with your scripted rest API to create incident. In your incident payload you are passing metadata for your attachment but not actual attachment itself.
Create Atachment in ServiceNow Using Attachment API and OAuth Authorization
Hope it helps.
Regards,
Shubham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2024 05:41 PM
Hi Shubham,
Thank for your mail. Client request as below. Both incident and attachment to be created at a time. That is why i am working on import set rather than scripted API.
{
"caller": "73A",
"short_description": "Issue with mobile device",
"description": "Issue with mobile device",
"level1": "iphone",
"level2": "Charging",
"attachments": [
{
"fileName": "example.txt",
"contentType": "text/plain",
"content": "VGhpcyBpcyBhIHNhbXBsZSBmaWxlIGNvbnRlbnQu"
}
]
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 06:27 AM
Hi Subham,
Thanks for the mail . I am testing this scripted API from Rest api explorer. Giving the below request body.
Request Body
{
"short_description":"Incdent is created from Innovaway",
"caller_id":"73A",
}
{
"short_description": "Issue with mobile device",
"caller_id": "73A",
"attachments": [
{
"file_name": "example.txt",
"content_type": "text/plain",
"file_content": "VGhpcyBpcyBhIHNhbXBsZSBmaWxlIGNvbnRlbnQu"
}
]
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 10:09 AM
Somehow i dont see the error , I saw the attachement created in sys_attachment table but its empty , also not attached to the incident