Skip to content

Instantly share code, notes, and snippets.

@jtabone16
Last active May 2, 2018 12:03
Show Gist options
  • Save jtabone16/5789644 to your computer and use it in GitHub Desktop.
Save jtabone16/5789644 to your computer and use it in GitHub Desktop.
Use of REST Assured to make GET and POST requests from ProctorCam's scheduling API (Java) to ProctorServ
public class RestRequestClient
{
public RestRequestClient()
{
}
public Response makeGetRequest(String url, String customer_identifier, String shared_secret, HashMap<String,Object> params)
{
HashedAuthenticator.applyReverseGuidAndSign(params, customer_identifier, shared_secret);
RestAssured.responseContentType("application/json");
Response response = RestAssured.given().contentType("application/json").and().parameters(params).get(url);
return response;
}
public Response makePostRequest(String url, String customer_identifier, String shared_secret, HashMap<String,Object> params)
{
HashedAuthenticator.applyReverseGuidAndSign(params, customer_identifier, shared_secret);
JSONObject jsonParams = new JSONObject();
String requestParams - jsonParams.putAll(params).valueToString();
RestAssured.responseContentType("application/json");
Response response = RestAssured.given().contentType("application/json").and().body(requestParams).post(url);
return response;
}
}
@ambikar
Copy link

ambikar commented Jun 22, 2016

Hi, what will you ideally pass in the params parameter. I tried to pass the json payload fie path but it doesnt work

@hero78
Copy link

hero78 commented May 2, 2018

thanks, this has saved me a lot of time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment