- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2024 11:37 PM
I need to send two dynamic parameters to the endpoint for querying. I confirmed that the token works properly. However, it returns no value, and when debugging, the endpoint remained unchanged without a value passed.
getACTIVITY2: function() {
try {
var r = new sn_ws.RESTMessageV2('CPNYCostCenter', 'Get ACTIVITY');
r.setStringParameterNoEscape('p_fund', 'AF'); //Hardcode for now to debug
r.setStringParameterNoEscape('p_org', 'CSIPM'); //Hardcode for now to debug
r.setRequestHeader('Authorization', 'Bearer ' + this.token);
var response2 = r.execute();
var responseBody2 = response2.getBody();
var httpStatus2 = response2.getStatusCode();
gs.info("The Activity: " + responseBody2); //return empty
gs.info("Endpoint: " + r.getEndpoint();) // return https:url.com//ServiceNow/getActivityList?p_org=${p_org}&p_fund=${p_fund} //Variable value did not pass into the endpoint
} catch (ex) {
var message = ex.message;
}
},
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 03:00 AM
You are posting the query parameters twice
If you do that you will get them twice
If using the HTTP Query Parameters you should not add anything in the path. It will add "?" as well as the parameters you hav added
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 12:19 AM
Hi @tsoct
what do you get the status code?
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 12:27 AM
Hello @dgarad ,
ResponseStatus: 200
I added content-type = application/json in the HTTP Method. And the activity now return
*** Script: The Activity: <HTML> <HEAD> <TITLE>Error 415--Unsupported Media Type</TITLE> </HEAD> <BODY bgcolor="white"> <FONT FACE=Helvetica><BR CLEAR=all> <TABLE border=0 cellspacing=5><TR><TD><BR CLEAR=all> <FONT FACE="Helvetica" COLOR="black" SIZE="3"><H2>Error 415--Unsupported Media Type</H2> </FONT></TD></TR> </TABLE> <TABLE border=0 width=100% cellpadding=10><TR><TD VALIGN=top WIDTH=100% BGCOLOR=white><FONT FACE="Courier New"><FONT FACE="Helvetica" SIZE="3"><H3>From RFC 2068 <i>Hypertext Transfer Protocol -- HTTP/1.1</i>:</H3> </FONT><FONT FACE="Helvetica" SIZE="3"><H4>10.4.16 415--Unsupported Media Type</H4> </TD></TR></TABLE> </BODY> </HTML>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 12:37 AM - edited 05-15-2024 12:38 AM
In the rest messages in the HTTP header add content-type = application/json.
Thanks
dgarad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 01:05 AM
Hi @dgarad ,
Added and the message i got:
*** Script: The Activity: <HTML> <HEAD> <TITLE>Error 415--Unsupported Media Type</TITLE> </HEAD> <BODY bgcolor="white"> <FONT FACE=Helvetica><BR CLEAR=all> <TABLE border=0 cellspacing=5><TR><TD><BR CLEAR=all> <FONT FACE="Helvetica" COLOR="black" SIZE="3"><H2>Error 415--Unsupported Media Type</H2> </FONT></TD></TR> </TABLE> <TABLE border=0 width=100% cellpadding=10><TR><TD VALIGN=top WIDTH=100% BGCOLOR=white><FONT FACE="Courier New"><FONT FACE="Helvetica" SIZE="3"><H3>From RFC 2068 <i>Hypertext Transfer Protocol -- HTTP/1.1</i>:</H3> </FONT><FONT FACE="Helvetica" SIZE="3"><H4>10.4.16 415--Unsupported Media Type</H4> </TD></TR></TABLE> </BODY> </HTML>