- 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 03:01 AM
Hello Sreejith,
1st, you cannot access the attachement table by default in servicenow.(You can by editing some properties, but its not a good practice and not useful)
2nd, Even if you actually changed the properties, the endpoint seems incorrect. endpoint should be more like /now/sys_attachment/......
3rd, You apprach towards the ecc_queue was the correct one. Please can you post the request as well? Also, try to get add some roles(itil) to the user you use to authenticate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 03:24 AM
Hello Santosh,
Thanks for your help.
Regarding the point 2, i have changed as you have mentioned but an error.
Response Status Code: 400
Response JSON Content: {u'status': u'failure', u'error': {u'message': u'Requested URI does not represent any resource: /now/sys_attachment/file', u'detail': None}}
Regarding the 3rd point, well i could attch with ecc_queue when the administrator grant me Discovery_Admin right but he said Discovery_Admin has too many permissions so he wants me to get exact permisson or acl in ecc_queue ,unfortunatly which i do not know.
The request i made is a below.
uri = "https://test-servicedesk.test.net/ecc_queue.do?JSONv2&sysparm_action=insert"
payloads = {
'agent':'AttachmentCreator',
'topic':'AttachmentCreator',
'name':'test2.csv:application/CSV',
'source':inc,
'payload':encoded_string
}
r = requests.post(url=uri, data=json.dumps(payloads),auth=auth,verify=False, headers=headers)
Response is 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'}
Thanks
Sree
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 03:32 AM
Well, We are using Geneva implementation instead and in Geneva its
POST /now/attachment/file
not ECC_queue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-10-2016 03:51 AM
Hello Sreejith,
HTTP POST calls to insert an attachment should be : POST https://<instance-name>.service-now.com/api/now/table/{tableName}
Table name for attachment in servicenow is sys_attachment. Although, sys_attachment table may or may not be enabled for web services.
Looking at your request, I can see some problems:
1. the value for 'source' should be '<table_name>:<sys_id of table name>' e.g., 'source' : 'incident:cc565618c0a80a6b00ff2a4d06a6b729'
2. In the line 'r = requests.post(url=uri, data=json.dumps(payloads),auth=auth,verify=False, headers=headers)', I am not sure what 'auth=auth' means, but the authentication should be 'basic', you should try using auth=basic instead?
3. There is definitely access issue, the user should have at least rest_service role, which should be enough. Please ask your admin to provide create access to your user(either by providing rest_service, or as per your design) for ecc_queue table.
Thanks