REST API response in Json format

salu
Mega Guru

Hello,

I am very new in the web service.

I want to access a third party URL and retrieve data in json format using get method.

I have created a REST message and using get method am expecting a json format but not coming as [],but status is 200.

What the step am missing here or how can make it working

find_real_file.png

find_real_file.png

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Saranya,



The status of 200 means a success. The response you should be able to get in logs using the below script



var r = new sn_ws.RESTMessageV2('getCartoon Number', 'get');  


// set various parameters which you want



var response = r.execute();  


var responseBody = response.getBody();  


var httpStatus = response.getStatusCode();  


gs.log(JSON.stringify(responseBody));



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

View solution in original post

9 REPLIES 9

Hello Ankur,



Thank for the reply.



I have tested with other olpn number and getting the json format.



The response coming as null [] might be missing in the external system?



Shall I request that server   team to check it?



Thanks


Saranya


Hi Saranya,



Yes you can check with them.


One thing which you can try is copy the endpoint along with the olpn number and directly visit that endpoint in browser. In ideal case it should give some response.



Regards


Ankur


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

Hello Ankur,


You are right.I have tried in the browser and there also it getting as null.



Thanks you very much for help



Thanks


Saranya


Hi Saranya,



One more thing you can add in the HTTP Request Header for Rest Message and Rest Message get method.


Name                                   Value


Content-Type           application/json



Regards


Ankur


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

swati38
Tera Expert

Hi Saranya,



When you click the link, what does it show?


I guess the content is not defined, you can either specify it in the query parameter.


and hard code the "olpn" value, instead of using in url.


you can use the variable in the query parameter.



thanks,


swati