Postman Attachment API Example
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2023 02:55 PM
- Create a new HTTP request
- Set type to "Post"
- Set URL to https://[INSTANCE_NAME].service-now.com/api/now/attachment/upload
- Add these headers:
- Accept = */*
- Content-type = application/json
- Switch to body tab, set to "form-data"
- Add these to body:
- table_name = [table name of record you want to attach the file to]
- table_sys_id = [sys_id of record you want to attach the file to]
- file = [upload a file]
- Change this type to "file" instead of text (see image below)
- Authorization - I'll give 2 ways to use basic auth
- Basic Auth - Unencrypted
- Open "Authorization" tab
- Set type to "Basic Auth"
- Add User Name and Password
- This will add "Authorization" to the headers tab after you click Send
- Basic Auth - Encrypted
- In the Authorization tab, set Type to "No Auth"
- Use the script below to encrypt your basic auth credentials
- In the headers, add "Authorization", set value to "Basic [INSERT OUTPUT OF SCRIPT]"
- Basic Auth - Unencrypted
- Click send
SCRIPT
var username = "my_username";
var password = "my_password";
encodedAuth = GlideStringUtil.base64Encode(username + ':' + password);
gs.print(encodedAuth);
- 2,470 Views
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2024 06:01 AM
Hi,
Do you have a working example for powershell please? I have been looking at this thread SOLUTION - How to attach a file to a record using ... - Page 2 - ServiceNow Community
However this does not work for me as I need all the oauth2 string for the code to gather the access token.