I am very newbie for this groovy programming. I have written an API which is running in my local system (localhost:2100
).
Now i want to make a simple GET request to this API using groovy code. I searched a lot for this but i cant find the clear guidance.
I tried for this :
http://www.kellyrob99.com/blog/2013/02/10/groovy-and-http/ http://rest.elkstein.org/2008/02/using-rest-in-groovy.html etc.. But nothing works.
Also i came across HttpBuilder
. I cant get clear idea of this. Please share your ideas.
EDIT:
I tried for this:
def client = new RESTClient("http://localhost:2100");
def res = client.get(path:"xxx/yyy/zzz")
I am receiving error:
Groovy:unable to resolve class RESTClient
Whether I need to add dependency in my pom.xml?
Open groovy script > Right click > Get data > Select the test case step which has the API call > Select request/response etc. The "request" is type of class java. lang. String.
URL url = new URL("http://192.168.1.87:8080/bridge/test.php"); URLConnection conn = url. openConnection();
If you need to do a simple GET petition. You can use the URL Class. For example, to get the content of example.org, with a GET request
new URL("http://example.org/").text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With