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_URLENCODED
JSON
(default)MULTIPART_FORM_DATA
PLAIN_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:
DELETE
GET
HEAD
OPTIONS
PATCH
POST
PUT
TRACE
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 ();