Notifications

2439 views

Description

The REST API Explorer is reporting incorrect information for the Attachment API upload curl snippets. If you try to copy/paste the curl snippet directly into a terminal, it will not work. See attachments for detailed problems with each upload curl snippet.

Steps to Reproduce

  1. Navigate to System Web Services > REST > REST API Explorer.
  2. Choose Attachment API as the API Name.
  3. Click Upload an attachment from a multipart form (POST).
  4. Input valid table_name and table_sys_id values, click Choose a file and select a file to upload, and click Send.
  5. Click the cURL code snippet link and observe.
  6. Repeat these steps but in Step 3, choose Upload an attachment from a binary request (POST).

Workaround

The correct curl statements are:

  • Upload an attachment from a multipart form (POST):
curl "https://<instance>/api/now/attachment/upload" \
--request POST \
--header "Accept: application/json" \
--user 'admin':'admin' \
--header "Content-Type:multipart/form-data" \
-F 'table_name=<name>' \
-F 'table_sys_id=<sys_id>' \
-F 'uploadFile=@location of the file on file system'

  • Upload an attachment from a binary request (POST):
curl "https://<instance>/api/now/attachment/file?table_name=<name>&table_sys_id=<sys_id>&file_name=<filename>" \
--request POST \
--header "Accept: application/json" \
--user 'admin':'admin' \
--header "Content-Type: <content_type>" \
--data-binary @path_to_file

Related Problem: PRB646918

Seen In

Geneva Patch 1 Hot Fix 7
Geneva Patch 7

Fixed In

Jakarta

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2016-10-10 16:26:07
Published:2015-09-11