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

Hey,



Could you please try this: GET /sn_sc/servicecatalog/items/${sys_id}



Let me know if this was helpful


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



Gives me a response of         "message": "Either Catalog Item is not valid or security constraints prevent access"



I tried an earlier test with https://MYINSTANCEREDACTED.service-now.com/api/sn_sc/servicecatalog/items/{03b153c92b4e85004f1c769bf8da152b}


just in case I was missing some REST syntax 101 and needed to include the brackets. This also results in the same message.



test 3.PNG


wryanr
Tera Contributor

I forgot to mention that I also tried this with an admin account to see if authentication was an issue. I can also browse to this catalog item while impersonating the user I'm using in these tests.