function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Charni Wiggins 9Charni Wiggins 9 

REST API endpoint changed - how did I test within dev console?

We recently had a contractor develop a simple API for us, who has since left and the endpoint has changed. I believe I have changed the endpoint where I need to. Is it possible to trigger the API via the dev console to test it? I was thinking using execute anonymous window. Would appreciate any help, as an admin! Thank you
Best Answer chosen by Charni Wiggins 9
SwethaSwetha (Salesforce Developers) 
HI Charni,
You can try the below code snippet in execute anonymous window

HttpRequest req = new HttpRequest();
req.setEndpoint('URL'); //Specify your URL here
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());

The system.debug will give you the response in debug logs.

Note: Make sure that the URL you would specify as an end point is added to remote site settings of your Org (Click path : Setup > Quick find> Remote Site Settings> )

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you

All Answers

SwethaSwetha (Salesforce Developers) 
HI Charni,
You can try the below code snippet in execute anonymous window

HttpRequest req = new HttpRequest();
req.setEndpoint('URL'); //Specify your URL here
req.setMethod('GET');
Http http = new Http();
HTTPResponse res = http.send(req);
System.debug(res.getBody());

The system.debug will give you the response in debug logs.

Note: Make sure that the URL you would specify as an end point is added to remote site settings of your Org (Click path : Setup > Quick find> Remote Site Settings> )

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
This was selected as the best answer
Charni Wiggins 9Charni Wiggins 9
This is exactly what I was looking for - thank you so much Swetha! :)