- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 12:55 AM
Hello,
I am trying to build an application that collect a report from another application,create an incident and attach to it. I wrote this application in Python. When ever i tried to to attach a file using ecc_queue i am getting an error as below.
Response Status Code: 200
Response JSON Content: {u'reason': None, u'error': u'Insufficient rights to insert records from the table: ecc_queue'}
when i contacted the servicenow administrator he said that ecc_queue is not secure plus he wants me to provide the exact acl in the ecc_queue,we are using geneva implementation. Later he told me to try Attachment API - POST /now/attachment/file.
I have tried this as per the documentation and i get below error.
Response Status Code: 400
Response JSON Content: {u'status': u'failure', u'error': {u'message': u'Attachment is empty', u'detail': None}}
I also tried Attachment API - GET /now/attachment/{sys_id}/file to check if i can retrive an exsisting attachment ,but i dint work as well. i get below error message.
Response Status Code: 404
Response JSON Content: {u'status': u'failure', u'error': {u'message': u'No Record found', u'detail': u"Record doesn't exist or ACL restricts the record retrieval"}}
Please help me.
Thanks
Sree
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 05:13 AM
Hi Sreejith,
Below code works perfectly fine in Fuji and Geneva, but there is a whole new Attachment API in Geneva as you mentioned,
POST Body
{
"agent":"AttachmentCreator",
"topic":"AttachmentCreator",
"name": "Issue_screenshot.jpg:application/jpg",
"source":"incident:Sys_ID",
"payload":"Base64_string_of_the_attachment"
}
I am currently exploring the Geneva API's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 06:27 AM
Hi Sree,
yes, this is what worked for me,
api/now/attachment/file?table_name=incident&table_sys_id=d71da88ac0a801670061eabfe4b28f77&file_name=issue_screenshot.jpg
Headers
application/json
image/jpeg
I am able to post an attachment successfully but when I try to view it on my Service Now instance it is just returning me the base64 format not actual image I guess we are missing something here..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 06:46 AM
api/now/attachment/file?table_name=incident&table_sys_id=f877829b63f35240f0917d7ad6ba9472&file_name=issue_screenshot.jpg'
headers = {"Content-Type":"image/jpeg","Accept":"application/json"}
But again i am getting the same error message as below.
Response Status Code: 400
Response JSON Content: {u'status': u'failure', u'error': {u'message': u'Attachment is empty', u'detail': None}}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 06:49 AM
Hi Sree,
How are you sending your attachment?
Please try to send it in Request body as Base64.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 06:55 AM
Hello,
I am sending like this
r = requests.post(url=url,verify=False,auth=(uname, pwd),headers=headers)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 06:58 AM
I also tried to encode the file and pass the encoded as attachment but again no luck
with open("Issue_screenshot.jpg","rb") as image_file:
encoded_string = base64.b64encode(image_file.read())