Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Error Invalid URL : REST API : GET Call : Ascii Code Encoding

Ketan Mittal1
Kilo Contributor

I am trying to do a get call via the Rest Messages for this endpoint : https://ocwen-sb.api.identitynow.com/beta/accounts?filters=sourceId eq "2c918084742b9e9a0174447f3d0d1821" and nativeIdentity eq "EXT100001"

However, when I try to run this, I get an error as "invalid URL".

Funny thing, this works well & good on the Postman. I searched a bit about this on google and got to know that apparently, some of these values need to be changes to ascii codes.

So I changed it to this : https://ocwen-sb.api.identitynow.com/beta/accounts?filters=(sourceId=2c918084742b9e9a0174447f3d0d1821&nativeIdentity=EXT100001)

Now I get "Method failed: (/beta/accounts) with code: 400"

{"detailCode":"400.1 Bad request content","trackingId":"7ed978c82e0540ebb13c9aec18c664ae","messages":[{"locale":"en-US","localeOrigin":"DEFAULT","text":"The request was syntactically correct but its content is semantically invalid."}]}

Couldn't find any solution. Need help.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Ketan Mittal 

I assume you must be setting the endpoint of the REST Message using setEndPoint()

please update as below

var sourceId = '2c918084742b9e9a0174447f3d0d1821';

var nativeIdentity = 'EXT100001';

var url = 'https://ocwen-sb.api.identitynow.com/beta/accounts?filters=(sourceId=' + sourceId + '&nativeIdentity=' + nativeIdentity + ')';

url = encodeURIComponent(url);

var request = new sn_ws.RESTMessageV2();
request.setEndpoint();
request.setHttpMethod('GET');

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

10 REPLIES 10

@Ketan Mittal 

I think you should mark the response which has the script or workaround so that it would be easier for future readers.

probably this one

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader