Attach a file using rest api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2016 11:47 AM
Hi
I am trying to attach a file to service now request.
I followed below method to attach the file
Method : https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/integrate/inbound_rest/reference/...
URL :
but getting below error , there must be something wrong how I specify the file name to attach Has any one encountered similar error or attached a file successfully.
i am getting below error
Curl output
===========
{"error":{"message":"Requested URI does not represent any resource","detail":"Requested URI does not represent any resou
rce Check logs for error trace or enable glide.rest.debug property to verify REST request processing"},"status":"failure
"}
Python script output
=================
('Status:', 400, 'Headers:', {'X-Cnection': 'close', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'Set-Cookie': 'JSESSIONID=B9AB8B6B0745ECDE3F736FB47CBAFCE5;Secure; Path=/; HttpOnly, BIGipServerpool_dev24647=3816850442.32576.0000; path=/', 'Strict-Transport-Security': 'max-age=15768000; includeSubDomains;', 'Server': 'ServiceNow', 'Date': 'Mon, 20 Jun 2016 18:26:24 GMT', 'Content-Type': 'application/json'}, 'Error Response:', {u'status': u'failure', u'error': {u'message': u'Requested URI does not represent any resource', u'detail': u'Requested URI does not represent any resource Check logs for error trace or enable glide.rest.debug property to verify REST request processing'}})
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2016 12:05 PM
It doesn't look like their sample Python script has any data in the post body. Here is a quick link on how to use requests.post for python. It should have a data="some data here" as a parameter into the post function call.
Quickstart — Requests 2.10.0 documentation
If you are simply playing around with the file API, try to use the cURL example they give on the page you linked to.
Edit: On the cURL call I forgot to mention that you will need to add "\" at the end of each line (except for the last) in bash. They didn't include them on lines 4 and 5. I ran the curl without the last slashes and received a similar message as yours.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-28-2016 06:27 AM
Hi Sanjeev,
Did you get around it? I am trying the same and seems like both the sample cURL and Python scripts dont work at all. I always get this error:
{"error":{"detail":null,"message":"Failed to create the attachment. File part might be missing in the request."},"status":"failure"}
Does anyone know what value to pass to uploadFile? It seems like Servicenow is unable to retrieve my attachment.
Thanks in advance
Dharshini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2016 09:17 AM
Hi Dharshini,
Were you able to get around this, i am trying to upload an attachment using REST API in Geneva, and hit on the same error?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2016 06:29 AM
Hi Karthik,
Yes, apparently we should use setRequestBodyFromAttachment() function to send files.
Wiki article is not that clear. But the above function sends a base64 encoded file to the endpoint.
Hope this helps