Create a record from REST API Explorer

Khanna Ji
Tera Guru

How can I create a record from the REST API explorer with an attachment? Please help me understand this part.

Basically I want to create a record and attach the file to that record from REST API explorer or any other API testing tools like POSTMAN

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@ServiceNow User 

Out of the box TABLE API would create record on your target table.

You would require one more API call on Attachment API to add attachment to the above record created

Screenshots below:

1) 1st create record in table using POST call and give the required fields you want

find_real_file.png

find_real_file.png

find_real_file.png

2) Now attach sample file by using that record sys_id which is highlighted in blue

Give table name, file name, record sys id

Request format as text/plain since I have given txt file

find_real_file.png

 

Output: File got attached

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Manoj Kumar16
Giga Guru

From Rest API explorer you need to make two REST API Requests- Please find the below screenshots for your reference

1. Create Record-

find_real_file.png

 

Json Body Format-

 

https://developer.servicenow.com/dev.do#!/reference/api/orlando/rest/c_TableAPI#r_TableAPI-POST

2. Attach the file

find_real_file.png

 

Json Body Format-

https://developer.servicenow.com/dev.do#!/reference/api/orlando/rest/c_AttachmentAPI#r_AttachmentAPI...

Megha Padale
Giga Guru

Hi,

Check the attachment API:

The Attachment API allows you to upload and query file attachments.
You can upload or retrieve a single file with each request.

https://developer.servicenow.com/dev.do#!/reference/api/orlando/rest/c_AttachmentAPI

Also check below threads similar to your thread

https://community.servicenow.com/community?id=community_question&sys_id=40206f39db1727404abd5583ca96...

https://community.servicenow.com/community?id=community_question&sys_id=6b30cf61db98dbc01dcaf3231f96...

If my answer helped you in any way, mark answer as helpful and correct.

Thanks and regards,

Megha.

Ankur Bawiskar
Tera Patron
Tera Patron

@ServiceNow User 

Out of the box TABLE API would create record on your target table.

You would require one more API call on Attachment API to add attachment to the above record created

Screenshots below:

1) 1st create record in table using POST call and give the required fields you want

find_real_file.png

find_real_file.png

find_real_file.png

2) Now attach sample file by using that record sys_id which is highlighted in blue

Give table name, file name, record sys id

Request format as text/plain since I have given txt file

find_real_file.png

 

Output: File got attached

find_real_file.png

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader