Inbound REST API With multiple request method types

Roger1
Tera Contributor

I'm used to creating endpoints that support multiple method types.  For example, I would create an endpoint ./user for request method GET, POST and PUT.  For GET methods, it would return the user.  For POST method, it would create a user and for PUT it would update the user.  When I set that up in ServiceNow, it seems that all requests were going into my GET method resource.  Does ServiceNow support creating multiple resources with the same end point, but different HTTP request method?

3 REPLIES 3

Abhijit
Tera Expert

Define scripted rest api for user endpoint and and then you can provide different methods to support this endpoint

 

Refer to some OOB Scripted rest api

 

Abhijit_0-1691609492247.png

 

 

 

Roger1
Tera Contributor

My bad.  My test setup on Postman was the issue.  It works.

Prabu Velayutha
Mega Sage
Mega Sage

@Roger1 are using the out of box user table API or the Scripted Rest API?

 

If your using the OOB or the Scripted Rest API you can make use of the Rest API explorer to test API request and response. Also you can easily build the request body and identify the API URL's for each method. Refer the screenshot below. 

 

 

PrabuVelayutha_0-1691618351226.png

 

example: 

POST https://urinstance.service-now.com/api/now/table/sys_user
GET https://urinstance.service-now.com/api/now/table/sys_user/{sys_id}

 

If my answer has helped with your question, please mark my answer as accepted solution and mark helpful.