NullPointerException on service catalog rest api GET /sn_sc/servicecatalog/items/{sys_id}

wryanr
Tera Contributor

I've been trying to learn the REST API and have hit a wall. I'm able to generate Incident and Change tickets and now I'm trying to create RITMs. I started by running some GET tests on the catalogs and categories and was successful at doing a GET /sn_sc/servicecatalog/items. When I tried to do a GET /sn_sc/servicecatalog/items/{sys_id} I kept getting a NullPointerException. Here are the details.

I started with the following GET (I'm using Postman if that matters). I have the authentication verified and all necessary roles, also verified.

https://MYINSTANCEREDACTED.service-now.com/api/sn_sc/servicecatalog/items

This gave me the expected result

success on items.PNG

Then I performed the next GET using a sys_id of an item from the result above. I also verified the sys_id in the instance from Maintain Items

https://MYINSTANCEREDACTED.service-now.com/api/sn_sc/servicecatalog/items/03b153c92b4e85004f1c769bf8...

I get the NullPointerException here.

error on item sys id.PNG

Any ideas on why the GET sys_id is failing?

1 ACCEPTED SOLUTION

wryanr
Tera Contributor

Well, I found the issue.




ServiceNow KB: SC Catalog Get API returning java.lang.NullPointerException if the "Data Lookup and R...



Looks like there's a plugin that activated in new instances, but not ones that are upgraded. I activated these plugins and the REST calls are working now.



Thanks for everyone's help.



William


View solution in original post

10 REPLIES 10

Hi William,



Using postman i sent in a request to retrieve the item details with the following details:-



URL   for Get Request   -   {URL}/api/sn_sc/v1/servicecatalog/items/060f3afa3731300054b6a3549dbe5d3e  



Replace URL with your instance url


Then added the following headers


Accept application/json


Content-Type application/json




Then added Basic Authorization with user name and password for authentication, once you do that please press the Update Request Button in postman so that it adds a third header called Authorization with a value once you have added the basic auth details. Please ensure the user whose auth details you are entering has the read access to the record.



Now sending the Get Request would fetch you the Item details only. I was able to verify this in Postman.


postman.png


Venkat,



That failed in my instance so I spun up a developer instance and repeated the setup and was successful. My instance is on Helsinki and the developer instance was Istanbul. The documentation suggests this is supported in Helsinki but maybe I'm wrong on that?



There's definitely something odd going on with my instance. I'm able to get some of the Service Catalog API calls to work, but not all of them.



GET /sn_sc/servicecatalog/catalogs == Success!


GET /sn_sc/servicecatalog/catalogs/{sys_id} == Success!


GET /sn_sc/servicecatalog/catalogs/{sys_id}/categories == Success!


GET /sn_sc/servicecatalog/categories/{sys_id} == Fails with   "message": "Requested URI does not represent any resource: /sn_sc/servicecatalog/catalogs/e0d08b13c3330100c8b837659bba8fb4/categories/e15706fc0a0a0aa7007fc21e1ab70c2f"   --- This category sys_id came from the results of the previous step.


venkatiyer1
Giga Guru

Hi William,



The same call worked for me in Helsinki as well. Ensure you are using basic auth with a database password when you are using postman if you have a proxy or single sign on enabled to test the rest call.



It is ironical to see some calls go through and some not. If you have already addressed my above statement you might need a hi ticket to see what is going on..


Venkat,



I tested with a local user, not an LDAP user and got the same results.



Thanks for your help. I'll open a HI ticket and see where we go from there.



William