Adding attachment to incident

grantmitchell
Kilo Explorer

Hi,

I have developed a program to add an attachment to an incident, however it doesn't seem to work unless the user using the API has admin access.

Following the guidance on AttachmentCreator SOAP Web Service - ServiceNow Wiki

Quote:
To create attachments, the SOAP user must have any roles required to create Attachment [sys_attachment] records, as well as the soap_create role, and any roles required to read and write records on the target table, such as the itil role to add attachments to incident records. By default there is no single role allowing you to add attachments. You can create a role to explicitly allow adding attachments, then assign this role to the SOAP user.

doesn't work, however giving the user Admin rights does.

As a regular user as defined above, the ticket can be created by the program, but when I do a call to add an attachment I get the following confusing message back:

Returned on failure:
Recv Content: {u'records': [{u'__status': u'success'}]}

If I give the user the admin roll I get:

Successful add (as admin):
Recv Content: {u'records': [{u'__status': u'success', u'queue': u'input', u'sys_updated_by': u'script_alerting', u'name': u'ongoing_2016-01-04_11:24:07.595499.html:text/html', u'error_string': u'', u'source': u'incident:94df15700f38d2405d1afc4ce1050e7c', u'sys_created_by': u'script_alerting', u'sys_updated_on': u'2016-01-04 11:24:07', u'sys_created_on': u'2016-01-04 11:24:07', u'sys_mod_count': u'0', u'agent': u'AttachmentCreator', u'topic': u'AttachmentCreator', u'from_sys_id': u'', u'state': u'processed', u'sys_id': u'4660a1b80ff8de00e9fabd5ce1050ebf', u'from_host': u'', u'processed': u'', u'response_to': u'', u'sequence': u'1520c6146810000001', u'payload': u"Attachment created and attached to 'incident' record with sys_id: '94df15700f38d2405d1afc4ce1050e7c'", u'agent_correlator': u''}]}

I am confused as to why both calls give a 200 response (I'd have expected a 201) and why the non-admin user returns success when it isn't successful (though it also returns 200.

We're running Fuji - What additional permissions do I need to give the user? Giving a script admin just to add an attachment isn't really a sane option. Thanks for any advice.

Grant.

4 REPLIES 4

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

Hi Grant,



This is how I would debug this:



1. Enable Debug All Security mode as admin user


2. Impersonate the SOAP user


3. Try to add an attachment to an incident and see what debug mode gives you. It might be that a particular ACL is preventing the insert of the attachment.



Regards,


Sergiu


The problem is that the user _can_ add via the gui without admin access, it just can't via the api. I'm not sure how we'd see debug info from api accesses. Is that possible?



Thanks,



Grant.


Hi Grant,



I don't know if API provides any debug information. But, usually on our side, if there are some errors, we get them in the application node logs. Have you checked System Log -> All to see if any information is available there?


Also, you could download the localhost_log via System Logs -> Utilities -> Node Log File Download and see if any information is available there.



If this doesn't reveal anything new, probably best way would be to open an incident with ServiceNow support.



Regards,


Sergiu


Inactive_Use603
Kilo Expert

this might help to understand the approach of sending files via Web Service ServiceNow Attachment Files via Web Service - YouTube