User is unauthorized to write to table: Incident, when trying to upload an attachment

ArnonLa
Tera Contributor

Hi,

I'm trying to use SNOW's Rest API to upload attachments to Incidents.

curl --location --request POST 'https://[...].service-now.com/now/attachment/file?table_name=incident&table_sys_id=[...]&file_name=[...]' \
--header 'Accept: application/json' \
--header 'Authorization: Basic [...]' \
--header 'Content-Type: [...]' \
--data-binary '[...]'

When I use a user with an admin role, the attachment is uploaded successfully.
When I use a none admin user, I'm getting the next error:
403 Forbidden - User not authorized. User is unauthorized to write to table: Incident

The same none admin user can successfully create and update Incidents using the Rest API. It only fails when trying to upload an attachment.
This user can upload attachments with no issues when using SNOW application in the browser.

I've tried adding to this user a few relevant Roles like: 
incident_manager, itil, rest_service, & sn_incident_write.

I've tried creating a new Role and then a few new ACLs that require this role.
ACL with create & write operations on the Incident and sys_attachment table.
I've assigned the new roles to this user but it didn't help.

Also tried to add the roles to:
System Properties -> Security -> List of roles (comma-separated) that can create attachments.

Nothing is helping.

Any idea?

9 REPLIES 9

ArnonLa
Tera Contributor

This issue is still not resolved. No matter what I try, I'm getting 'User is unauthorized to write to table: Incident' unless I add the admin role.

Hi Arnonla,

Did you get any Resolution for the issue?

 

I'm having this exact issue.  Can you please post your solution?  I can not see your solution in this thread.

 

Thank you,

Patrick Shea

 


Hi @AUEagle @ArnonLa 


I suggest opting for a scripted API approach to incorporate attachments into records rather than relying on the attachment API. This approach provides greater flexibility for managing attachments and controlling access based on your custom scripted API design.

here is great articles by Ankur.


https://www.servicenow.com/community/developer-forum/how-to-attach-file-in-incident-via-api/m-p/1675...

https://www.servicenow.com/community/itsm-forum/scripted-rest-api-to-update-incident-with-attachment...

 

If my response helped you anyways please consider marking this response as helpful / correct answer.

 

Thank you,
Nitin

 

Kamil22
Tera Contributor

Do you have role snc_read_only added to your user? If so remove it. Please let me know it this was it.