Last active
May 2, 2018 12:03
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, what will you ideally pass in the params parameter. I tried to pass the json payload fie path but it doesnt work