401 when not selected Apply to all resources

Peter Xiang
Tera Expert

Hi All,

I following ths article and then created an API key in my instance.

But if I not select "Apply to all resources" then selected my specify resource, the response is 401, User is not authenticated.

PeterXiang_5-1759032054630.png

 


PeterXiang_1-1759031813500.png

 

if I selected "Apply to all resources", the response is 200. Anyone can help me?

PeterXiang_2-1759031871513.png
PeterXiang_3-1759031917371.png

 

1 REPLY 1

Deepak Shaerma
Kilo Sage

Hi @Peter Xiang 

The 401 Unauthorized happens because your specific resource path (with PATCH) is not matching exactly with what ServiceNow expects. When you enable Apply to all resources, it bypasses that strict match and applies globally.

When you check Apply to all resources, the policy applies to every resource under that REST API regardless of the specific resource path → so authentication works fine → you get 200 OK.

Please mark this Helpful and Accepted Solution if this helps you. Your action will help me and the community in understanding same requirements.

Thanks & Regards

Deepak Sharma