ApiRequest
createRequestâ
This is a builder method to build ApiRequest instance.
Always start composing the request with createRequest method.
final ApiRequest request = ApiRequest.createRequest ()
.method (GET)
.path ("/users/${userId}")
.pathParam ("userId", "2")
.create ();
contentTypeâ
This method is used to set the content type of the request. Allowed values are:
FORM_URLENCODEDJSON(default)MULTIPART_FORM_DATAPLAIN_TEXT
final ApiRequest request = ApiRequest.createRequest ()
.contentType (ContentType.JSON)
.method (GET)
.path ("/users/${userId}")
.pathParam ("userId", "2")
.create ();
headerâ
This method is used to set the header of the request.
final ApiRequest request = ApiRequest.createRequest ()
.contentType (ContentType.JSON)
.header ("Header-Key-1", "Header value 1")
.header ("Header-Key-2", "Header value 2")
.method (GET)
.path ("/users/${userId}")
.pathParam ("userId", "2")
.create ();
pathâ
This method is used to set the path of the request.
final ApiRequest request = ApiRequest.createRequest ()
.contentType (ContentType.JSON)
.header ("Header-Key-1", "Header value 1")
.header ("Header-Key-2", "Header value 2")
.method (GET)
.path ("/users/${userId}")
.pathParam ("userId", "2")
.create ();
pathParamâ
This method is used to set the path parameter(s) of the request.
final ApiRequest request = ApiRequest.createRequest ()
.contentType (ContentType.JSON)
.header ("Header-Key-1", "Header value 1")
.header ("Header-Key-2", "Header value 2")
.method (GET)
.path ("/users/${userId}")
.pathParam ("userId", "2")
.create ();
queryParamâ
This method is used to set the query parameter(s) of the request.
final ApiRequest request = ApiRequest.createRequest ()
.contentType (ContentType.JSON)
.header ("Header-Key-1", "Header value 1")
.header ("Header-Key-2", "Header value 2")
.method (GET)
.path ("/users/${userId}")
.pathParam ("userId", "2")
.queryParam ("param1", "value1")
.create ();
bodyâ
This method is used to set the body of the request.
final ApiRequest request = ApiRequest.createRequest ()
.method (POST)
.path ("/users")
.body ("{\"name\":\"John\",\"job\":\"Developer\"}")
.create ();
bodyObjectâ
This method is used to set the body of the request using Java object.
final User user = User.createUser ()
.name ("Wasiq")
.job ("Software Engineer")
.create ();
final ApiRequest request = ApiRequest.createRequest ()
.method (POST)
.path ("/users")
.bodyObject (user)
.create ();
formBodyâ
This method is used to set the Form body of the request using key and value pairs.
final ApiRequest request = ApiRequest.createRequest ()
.method (POST)
.path ("/users")
.formBody ("strange", "boom")
.formBody ("test", "abc")
.create ();
methodâ
This method is used to set the method of the request. Following are the allowed values:
DELETEGETHEADOPTIONSPATCHPOSTPUTTRACE
final ApiRequest request = ApiRequest.createRequest ()
.method (RequestMethod.POST)
.path ("/users")
.bodyObject (user)
.create ();
userNameâ
This method is used to set the user name of the request.
final ApiRequest request = ApiRequest.createRequest ()
.method (POST)
.path ("/users")
.userName ("wasiq")
.password ("123456")
.bodyObject (user)
.create ();
passwordâ
This method is used to set the password of the request.
final ApiRequest request = ApiRequest.createRequest ()
.method (POST)
.path ("/users")
.userName ("wasiq")
.password ("123456")
.bodyObject (user)
.create ();
createâ
This method will create ApiRequest instance.
Always end composing the request with create method.
final ApiRequest request = ApiRequest.createRequest ()
.method (GET)
.path ("/users/${userId}")
.pathParam ("userId", "2")
.create ();