- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2020 09:00 AM
I have created a scripted REST API that requires a single query parameter.
I have set up a Query Parameter Association for that parameter and marked 'API query parameter Is required' true.
I fail to see what this achieves though. I tested the below scenarios:
https://instance.service-now.com/api/allrp/endpoint?param1= Server Status 500
https://instance.service-now.com/api/allrp/endpoint?param1 Server Status 500
https://instance.service-now.com/api/allrp/endpoint?param1="" Server Status 200
https://instance.service-now.com/api/allrp/endpoint? Server Status 200
I thought having 'API query parameter Is required' true; might have returned something other than a 500 with a related error message that param1 was required.
What functionality therefore is my Query Parameter Associations performing?
Thanks
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2020 03:16 PM
According to the documentation, checking "is required" is suppose to make the parameter mandatory but in actually, it doesn't do anything. Tested it myself too.
What it did was just add an entry field in REST API Explorer to enter a value of the parameter but if I didn't enter anything, the parameter wasn't sent.
I have request format to application/json so I'll need to do a manual check in my script.
var queryParams = request.queryParams;
var param1 = queryParams.param1;
if (!param1) {
response.setError(new sn_ws_err.BadRequestError('missing required parameter'));
return;
} else {
param1 = param1[0];
EDIT: BTW, I've tested this on Paris so versioning up won't fix the problem.
Should raise a HI ticket to report this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-17-2020 03:16 PM
According to the documentation, checking "is required" is suppose to make the parameter mandatory but in actually, it doesn't do anything. Tested it myself too.
What it did was just add an entry field in REST API Explorer to enter a value of the parameter but if I didn't enter anything, the parameter wasn't sent.
I have request format to application/json so I'll need to do a manual check in my script.
var queryParams = request.queryParams;
var param1 = queryParams.param1;
if (!param1) {
response.setError(new sn_ws_err.BadRequestError('missing required parameter'));
return;
} else {
param1 = param1[0];
EDIT: BTW, I've tested this on Paris so versioning up won't fix the problem.
Should raise a HI ticket to report this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-18-2020 03:07 AM
Thanks for the reply and confirmation. I will go with the manual check you have suggested also.