The CreatorCon Call for Content is officially open! Get started here.

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

Hi,

please keep that endpoint as empty and set it via script 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

I encoded this part - sourceId eq "2c918084742b9e9a0174447f3d0d1821" and nativeIdentity eq "EXT100001" via an online tool.

Append the encoded part to base URL to get the below. Try testing with this:

https://ocwen-sb.api.identitynow.com/beta/accounts?filters=sourceId%20eq%20%222c918084742b9e9a0174447f3d0d1821%22%20and%20nativeIdentity%20eq%20%22EXT100001%22

 

Thanks

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

Ankur Bawiskar
Tera Patron
Tera Patron

@Ketan Mittal 

Hope you are doing good.

Let me know if I have answered your question.

If so, please mark appropriate answer as correct & helpful to close the thread.

If not, please let us know if you need some more assistance.

Regards
Ankur

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

Thanks Ankur. This helps.