I want to call a REST APi with a authorization token via my groovy script. How may i do this?
Go to Solution.
You can use Java - Unirest to send the API request with authorization token:-
//Considering you have already fetched the Authorization Token
import com.mashape.unirest.http.Unirest;import com.mashape.unirest.http.HttpResponse; String accessToken = "Your Authorization Token"
String token_appender = "?access_token=" + accessToken;
HttpResponse<String> response = Unirest.get("API URL" + token_appender)
String responseBody = response.getBody().toString();
System.out.println("********** Response Generated **********");
This is the easiest way to do it.
If it really helped you out. Please accept as solution and don't forget to give kudos.
View solution in original post
This is because of test automation; we need to verify some condition and in case trigger calling an API with sending some params such as Authentication Token, etc
Did any of the suggestions given here help you? If so, please click the Accept as a Solution button next to the post that helped you.