com.jayway.restassured.builder
Class RequestSpecBuilder

java.lang.Object
  extended by com.jayway.restassured.builder.RequestSpecBuilder

public class RequestSpecBuilder
extends Object

You can use the builder to construct a request specification. The specification can be used as e.g.

 ResponseSpecification responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
 RequestSpecification requestSpec = new RequestSpecBuilder().addParam("parameter1", "value1").build();

 given(responseSpec, requestSpec).post("/something");
 
or
 RequestSpecification requestSpec = new RequestSpecBuilder().addParameter("parameter1", "value1").build();

 given().
         spec(requestSpec).
 expect().
         body("x.y.z", equalTo("something")).
 when().
        get("/something");
 


Constructor Summary
RequestSpecBuilder()
           
 
Method Summary
 RequestSpecBuilder addCookie(String key)
          Add a cookie without value to be sent with the request.
 RequestSpecBuilder addCookie(String key, Object value)
          Add a cookie to be sent with the request.
 RequestSpecBuilder addCookies(Map<String,?> cookies)
          Add cookies to be sent with the request as Map e.g:
 RequestSpecBuilder addFilter(Filter filter)
          Add a filter that will be used in the request.
 RequestSpecBuilder addFilters(List<Filter> filters)
          Add filters that will be used in the request.
 RequestSpecBuilder addFormParam(String parameterName, List<?> parameterValues)
          A slightly shorter version of addFormParameter(String, java.util.List).
 RequestSpecBuilder addFormParam(String parameterName, Object parameterValue, Object... additionalParameterValues)
          A slightly shorter version of addFormParameter(String, Object, Object...).
 RequestSpecBuilder addFormParameter(String parameterName, List<?> parameterValues)
          Add a form parameter to be sent with the request.
 RequestSpecBuilder addFormParameter(String parameterName, Object parameterValue, Object... additionalParameterValues)
          Add a form parameter to be sent with the request.
 RequestSpecBuilder addFormParameters(Map<String,?> parametersMap)
          Add query parameters to be sent with the request as a Map.
 RequestSpecBuilder addFormParams(Map<String,?> parametersMap)
          A slightly shorter version of addFormParameters(Map).
 RequestSpecBuilder addHeader(String headerName, String headerValue)
          Add a header to be sent with the request e.g:
 RequestSpecBuilder addHeaders(Map<String,String> headers)
          Add headers to be sent with the request as Map.
 RequestSpecBuilder addMultiPart(File file)
          Specify a file to upload to the server using multi-part form data uploading.
 RequestSpecBuilder addMultiPart(String controlName, File file)
          Specify a file to upload to the server using multi-part form data uploading with a specific control name.
 RequestSpecBuilder addMultiPart(String controlName, File file, String mimeType)
          Specify a file to upload to the server using multi-part form data uploading with a specific control name and content-type.
 RequestSpecBuilder addMultiPart(String controlName, String contentBody)
          Specify a string to send to the server using multi-part form data.
 RequestSpecBuilder addMultiPart(String controlName, String fileName, byte[] bytes)
          Specify a byte-array to upload to the server using multi-part form data.
 RequestSpecBuilder addMultiPart(String controlName, String fileName, byte[] bytes, String mimeType)
          Specify a byte-array to upload to the server using multi-part form data.
 RequestSpecBuilder addMultiPart(String controlName, String fileName, InputStream stream)
          Specify an inputstream to upload to the server using multi-part form data.
 RequestSpecBuilder addMultiPart(String controlName, String fileName, InputStream stream, String mimeType)
          Specify an inputstream to upload to the server using multi-part form data.
 RequestSpecBuilder addMultiPart(String controlName, String contentBody, String mimeType)
          Specify a string to send to the server using multi-part form data with a specific mime-type.
 RequestSpecBuilder addParam(String parameterName, List<?> parameterValues)
          A slightly shorter version of addParameter(String, java.util.List).
 RequestSpecBuilder addParam(String parameterName, Object parameterValue, Object... additionalParameterValues)
          A slightly shorter version of addParameter(String, Object, Object...).
 RequestSpecBuilder addParameter(String parameterName, List<?> parameterValues)
          Add a multi-value parameter to be sent with the request.
 RequestSpecBuilder addParameter(String parameterName, Object parameterValue, Object... additionalParameterValues)
          Add a parameter to be sent with the request.
 RequestSpecBuilder addParameters(Map<String,?> parametersMap)
          Add parameters to be sent with the request as Map.
 RequestSpecBuilder addParams(Map<String,?> parametersMap)
          A slightly shorter version of addParameters(Map).
 RequestSpecBuilder addPathParam(String parameterName, Object parameterValue)
          A slightly shorter version of addPathParameter(String, Object).
 RequestSpecBuilder addPathParameter(String parameterName, Object parameterValue)
          Specify a path parameter.
 RequestSpecBuilder addPathParameters(Map<String,?> parameterNameValuePairs)
          Specify multiple path parameter name-value pairs.
 RequestSpecBuilder addPathParameters(String firstParameterName, Object firstParameterValue, Object... parameterNameValuePairs)
          Specify multiple path parameter name-value pairs.
 RequestSpecBuilder addPathParams(Map<String,?> parameterNameValuePairs)
          A slightly shorter version of addPathParameters(java.util.Map).
 RequestSpecBuilder addPathParams(String firstParameterName, Object firstParameterValue, Object... parameterNameValuePairs)
          A slightly shorter version of addPathParameters(String, Object, Object...).
 RequestSpecBuilder addQueryParam(String parameterName, List<?> parameterValues)
          A slightly shorter version of addQueryParameter(String, java.util.List).
 RequestSpecBuilder addQueryParam(String parameterName, Object parameterValue, Object... additionalParameterValues)
          A slightly shorter version of addQueryParameter(String, Object, Object...).
 RequestSpecBuilder addQueryParameter(String parameterName, List<?> parameterValues)
          Add a query parameter to be sent with the request.
 RequestSpecBuilder addQueryParameter(String parameterName, Object parameterValue, Object... additionalParameterValues)
          Add a query parameter to be sent with the request.
 RequestSpecBuilder addQueryParameters(Map<String,?> parametersMap)
          Add query parameters to be sent with the request as a Map.
 RequestSpecBuilder addQueryParams(Map<String,?> parametersMap)
          A slightly shorter version of addQueryParameters(Map).
 RequestSpecBuilder addRequestSpecification(RequestSpecification specification)
          Merge this builder with settings from another specification.
 RequestSpecification build()
          Build the request specification.
 RequestSpecBuilder setAuth(AuthenticationScheme auth)
          A slightly short version of setAuthentication(com.jayway.restassured.authentication.AuthenticationScheme) )}.
 RequestSpecBuilder setAuthentication(AuthenticationScheme auth)
          If you need to specify some credentials when performing a request.
 RequestSpecBuilder setBody(byte[] body)
          Specify a byte array request body to be sent with the request.
 RequestSpecBuilder setBody(String body)
          Specify a String request body (such as e.g.
 RequestSpecBuilder setConfig(RestAssuredConfig config)
          Define a configuration for redirection settings and http client parameters.
 RequestSpecBuilder setContent(byte[] content)
          Specify a byte array request content to be sent with the request.
 RequestSpecBuilder setContent(String content)
          Specify a String request content (such as e.g.
 RequestSpecBuilder setContentType(groovyx.net.http.ContentType contentType)
          Specify the content type of the request.
 RequestSpecBuilder setContentType(String contentType)
          Specify the content type of the request as string.
 RequestSpecBuilder setKeystore(String pathToJks, String password)
          The following documentation is taken from http://groovy.codehaus.org/modules/http-builder/doc/ssl.html:
 RequestSpecBuilder setPort(int port)
          Specify the port.
 RequestSpecBuilder setUrlEncodingEnabled(boolean isEnabled)
          Specifies if Rest Assured should url encode the URL automatically.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RequestSpecBuilder

public RequestSpecBuilder()
Method Detail

setBody

public RequestSpecBuilder setBody(String body)
Specify a String request body (such as e.g. JSON or XML) to be sent with the request. This works for the POST and PUT methods only. Trying to do this for the other http methods will cause an exception to be thrown.

Note that setBody(String) and setContent(String) are the same except for the syntactic difference.

Parameters:
body - The body to send.
Returns:
The request specification builder

setBody

public RequestSpecBuilder setBody(byte[] body)
Specify a byte array request body to be sent with the request. This only works for the POST http method. Trying to do this for the other http methods will cause an exception to be thrown.

Note that setBody(byte[]) and setContent(byte[]) are the same except for the syntactic difference.

Parameters:
body - The body to send.
Returns:
The request specification builder

setContent

public RequestSpecBuilder setContent(String content)
Specify a String request content (such as e.g. JSON or XML) to be sent with the request. This works for the POST and PUT methods only. Trying to do this for the other http methods will cause an exception to be thrown.

Note that setBody(String) and setContent(String) are the same except for the syntactic difference.

Parameters:
content - The content to send.
Returns:
The request specification builder

setContent

public RequestSpecBuilder setContent(byte[] content)
Specify a byte array request content to be sent with the request. This only works for the POST http method. Trying to do this for the other http methods will cause an exception to be thrown.

Note that setBody(byte[]) and setContent(byte[]) are the same except for the syntactic difference.

Parameters:
content - The content to send.
Returns:
The request specification builder

addCookies

public RequestSpecBuilder addCookies(Map<String,?> cookies)
Add cookies to be sent with the request as Map e.g:

Parameters:
cookies - The Map containing the cookie names and their values to set in the request.
Returns:
The request specification builder

addCookie

public RequestSpecBuilder addCookie(String key,
                                    Object value)
Add a cookie to be sent with the request.

Parameters:
key - The cookie key
value - The cookie value
Returns:
The request specification builder

addCookie

public RequestSpecBuilder addCookie(String key)
Add a cookie without value to be sent with the request.

Parameters:
key - The cookie key
Returns:
The request specification builder

addFilter

public RequestSpecBuilder addFilter(Filter filter)
Add a filter that will be used in the request.

Parameters:
filter - The filter to add
Returns:
the request specification builder

addFilters

public RequestSpecBuilder addFilters(List<Filter> filters)
Add filters that will be used in the request.

Parameters:
filters - The filters to add
Returns:
the request specification builder

addParameters

public RequestSpecBuilder addParameters(Map<String,?> parametersMap)
Add parameters to be sent with the request as Map.

Parameters:
parametersMap - The Map containing the parameter names and their values to send with the request.
Returns:
The request specification builder

addParameter

public RequestSpecBuilder addParameter(String parameterName,
                                       Object parameterValue,
                                       Object... additionalParameterValues)
Add a parameter to be sent with the request.

Parameters:
parameterName - The parameter key
parameterValue - The parameter value
additionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
Returns:
The request specification builder

addParameter

public RequestSpecBuilder addParameter(String parameterName,
                                       List<?> parameterValues)
Add a multi-value parameter to be sent with the request.

Parameters:
parameterName - The parameter key
parameterValues - The parameter values
Returns:
The request specification builder

addParams

public RequestSpecBuilder addParams(Map<String,?> parametersMap)
A slightly shorter version of addParameters(Map).

Parameters:
parametersMap - The Map containing the parameter names and their values to send with the request.
Returns:
The request specification builder

addParam

public RequestSpecBuilder addParam(String parameterName,
                                   Object parameterValue,
                                   Object... additionalParameterValues)
A slightly shorter version of addParameter(String, Object, Object...).

Parameters:
parameterName - The parameter key
parameterValue - The parameter value
additionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
Returns:
The request specification builder
See Also:
addParameter(String, Object, Object...)

addParam

public RequestSpecBuilder addParam(String parameterName,
                                   List<?> parameterValues)
A slightly shorter version of addParameter(String, java.util.List).

Parameters:
parameterName - The parameter key
parameterValues - The parameter values
Returns:
The request specification builder
See Also:
addParameter(String, Object, Object...)

addQueryParameters

public RequestSpecBuilder addQueryParameters(Map<String,?> parametersMap)
Add query parameters to be sent with the request as a Map. This method is the same as addParameters(java.util.Map) for all HTTP methods except POST where this method can be used to differentiate between form and query params.

Parameters:
parametersMap - The Map containing the parameter names and their values to send with the request.
Returns:
The request specification builder

addQueryParameter

public RequestSpecBuilder addQueryParameter(String parameterName,
                                            Object parameterValue,
                                            Object... additionalParameterValues)
Add a query parameter to be sent with the request. This method is the same as addParameter(String, Object, Object...) )} for all HTTP methods except POST where this method can be used to differentiate between form and query params.

Parameters:
parameterName - The parameter key
parameterValue - The parameter value
additionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
Returns:
The request specification builder

addQueryParameter

public RequestSpecBuilder addQueryParameter(String parameterName,
                                            List<?> parameterValues)
Add a query parameter to be sent with the request. This method is the same as addParameter(String, java.util.List) for all HTTP methods except POST where this method can be used to differentiate between form and query params.

Parameters:
parameterName - The parameter key
parameterValues - The parameter values
Returns:
The request specification builder

addQueryParam

public RequestSpecBuilder addQueryParam(String parameterName,
                                        List<?> parameterValues)
A slightly shorter version of addQueryParameter(String, java.util.List).

Parameters:
parameterName - The parameter key
parameterValues - The parameter values
Returns:
The request specification builder
See Also:
addQueryParam(String, Object, Object...)

addQueryParams

public RequestSpecBuilder addQueryParams(Map<String,?> parametersMap)
A slightly shorter version of addQueryParameters(Map).

Parameters:
parametersMap - The Map containing the parameter names and their values to send with the request.
Returns:
The request specification builder
See Also:
addQueryParameters(java.util.Map)

addQueryParam

public RequestSpecBuilder addQueryParam(String parameterName,
                                        Object parameterValue,
                                        Object... additionalParameterValues)
A slightly shorter version of addQueryParameter(String, Object, Object...).

Parameters:
parameterName - The parameter key
parameterValue - The parameter value
additionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
Returns:
The request specification builder
See Also:
addQueryParam(String, Object, Object...)

addFormParameters

public RequestSpecBuilder addFormParameters(Map<String,?> parametersMap)
Add query parameters to be sent with the request as a Map. This method is the same as addParameters(java.util.Map) for all HTTP methods except POST where this method can be used to differentiate between form and query params.

Parameters:
parametersMap - The Map containing the parameter names and their values to send with the request.
Returns:
The request specification builder

addFormParameter

public RequestSpecBuilder addFormParameter(String parameterName,
                                           Object parameterValue,
                                           Object... additionalParameterValues)
Add a form parameter to be sent with the request. This method is the same as addParameter(String, Object, Object...) )} for all HTTP methods except PUT where this method can be used to differentiate between form and query params.

Parameters:
parameterName - The parameter key
parameterValue - The parameter value
additionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
Returns:
The request specification builder

addFormParameter

public RequestSpecBuilder addFormParameter(String parameterName,
                                           List<?> parameterValues)
Add a form parameter to be sent with the request. This method is the same as addParameter(String, java.util.List) for all HTTP methods except PUT where this method can be used to differentiate between form and query params.

Parameters:
parameterName - The parameter key
parameterValues - The parameter values
Returns:
The request specification builder

addFormParam

public RequestSpecBuilder addFormParam(String parameterName,
                                       List<?> parameterValues)
A slightly shorter version of addFormParameter(String, java.util.List).

Parameters:
parameterName - The parameter key
parameterValues - The parameter values
Returns:
The request specification builder
See Also:
addFormParam(String, Object, Object...)

addFormParams

public RequestSpecBuilder addFormParams(Map<String,?> parametersMap)
A slightly shorter version of addFormParameters(Map).

Parameters:
parametersMap - The Map containing the parameter names and their values to send with the request.
Returns:
The request specification builder
See Also:
addFormParameters(java.util.Map)

addFormParam

public RequestSpecBuilder addFormParam(String parameterName,
                                       Object parameterValue,
                                       Object... additionalParameterValues)
A slightly shorter version of addFormParameter(String, Object, Object...).

Parameters:
parameterName - The parameter key
parameterValue - The parameter value
additionalParameterValues - Additional parameter values if you want to specify multiple values for the same parameter
Returns:
The request specification builder
See Also:
addFormParam(String, Object, Object...)

addPathParameter

public RequestSpecBuilder addPathParameter(String parameterName,
                                           Object parameterValue)
Specify a path parameter. Path parameters are used to improve readability of the request path. E.g. instead of writing:
 expect().statusCode(200).when().get("/item/"+myItem.getItemNumber()+"/buy/"+2);
 
you can write:
 given().
         pathParameter("itemNumber", myItem.getItemNumber()).
         pathParameter("amount", 2).
 expect().
          statusCode(200).
 when().
        get("/item/{itemNumber}/buy/{amount}");
 
which improves readability and allows the path to be reusable in many tests. Another alternative is to use:
 expect().statusCode(200).when().get("/item/{itemNumber}/buy/{amount}", myItem.getItemNumber(), 2);
 

Parameters:
parameterName - The parameter key
parameterValue - The parameter value
Returns:
The request specification

addPathParameters

public RequestSpecBuilder addPathParameters(String firstParameterName,
                                            Object firstParameterValue,
                                            Object... parameterNameValuePairs)
Specify multiple path parameter name-value pairs. Path parameters are used to improve readability of the request path. E.g. instead of writing:
 expect().statusCode(200).when().get("/item/"+myItem.getItemNumber()+"/buy/"+2);
 
you can write:
 given().
         pathParameters("itemNumber", myItem.getItemNumber(), "amount", 2).
 expect().
          statusCode(200).
 when().
        get("/item/{itemNumber}/buy/{amount}");
 
which improves readability and allows the path to be reusable in many tests. Another alternative is to use:
 expect().statusCode(200).when().get("/item/{itemNumber}/buy/{amount}", myItem.getItemNumber(), 2);
 

Parameters:
firstParameterName - The name of the first parameter
firstParameterValue - The value of the first parameter
parameterNameValuePairs - Additional parameters in name-value pairs.
Returns:
The request specification

addPathParameters

public RequestSpecBuilder addPathParameters(Map<String,?> parameterNameValuePairs)
Specify multiple path parameter name-value pairs. Path parameters are used to improve readability of the request path. E.g. instead of writing:
 expect().statusCode(200).when().get("/item/"+myItem.getItemNumber()+"/buy/"+2);
 
you can write:
 Map<String,Object> pathParams = new HashMap<String,Object>();
 pathParams.add("itemNumber",myItem.getItemNumber());
 pathParams.add("amount",2);

 given().
         pathParameters(pathParams).
 expect().
          statusCode(200).
 when().
        get("/item/{itemNumber}/buy/{amount}");
 
which improves readability and allows the path to be reusable in many tests. Another alternative is to use:
 expect().statusCode(200).when().get("/item/{itemNumber}/buy/{amount}", myItem.getItemNumber(), 2);
 

Parameters:
parameterNameValuePairs - A map containing the path parameters.
Returns:
The request specification

addPathParam

public RequestSpecBuilder addPathParam(String parameterName,
                                       Object parameterValue)
A slightly shorter version of addPathParameter(String, Object).

Parameters:
parameterName - The parameter key
parameterValue - The parameter value
Returns:
The request specification
See Also:
addPathParameter(String, Object)

addPathParams

public RequestSpecBuilder addPathParams(String firstParameterName,
                                        Object firstParameterValue,
                                        Object... parameterNameValuePairs)
A slightly shorter version of addPathParameters(String, Object, Object...).

Parameters:
firstParameterName - The name of the first parameter
firstParameterValue - The value of the first parameter
parameterNameValuePairs - Additional parameters in name-value pairs.
Returns:
The request specification
See Also:
addPathParameters(String, Object, Object...)

addPathParams

public RequestSpecBuilder addPathParams(Map<String,?> parameterNameValuePairs)
A slightly shorter version of addPathParameters(java.util.Map).

Parameters:
parameterNameValuePairs - A map containing the path parameters.
Returns:
The request specification
See Also:
addPathParameters(java.util.Map)

setKeystore

public RequestSpecBuilder setKeystore(String pathToJks,
                                      String password)
The following documentation is taken from http://groovy.codehaus.org/modules/http-builder/doc/ssl.html:

SSL Configuration

SSL should, for the most part, "just work." There are a few situations where it is not completely intuitive. You can follow the example below, or see HttpClient's SSLSocketFactory documentation for more information.

SSLPeerUnverifiedException

If you can't connect to an SSL website, it is likely because the certificate chain is not trusted. This is an Apache HttpClient issue, but explained here for convenience. To correct the untrusted certificate, you need to import a certificate into an SSL truststore. First, export a certificate from the website using your browser. For example, if you go to https://dev.java.net in Firefox, you will probably get a warning in your browser. Choose "Add Exception," "Get Certificate," "View," "Details tab." Choose a certificate in the chain and export it as a PEM file. You can view the details of the exported certificate like so:
 $ keytool -printcert -file EquifaxSecureGlobaleBusinessCA-1.crt
 Owner: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US
 Issuer: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US
 Serial number: 1
 Valid from: Mon Jun 21 00:00:00 EDT 1999 until: Sun Jun 21 00:00:00 EDT 2020
 Certificate fingerprints:
 MD5:  8F:5D:77:06:27:C4:98:3C:5B:93:78:E7:D7:7D:9B:CC
 SHA1: 7E:78:4A:10:1C:82:65:CC:2D:E1:F1:6D:47:B4:40:CA:D9:0A:19:45
 Signature algorithm name: MD5withRSA
 Version: 3
 ....
 
Now, import that into a Java keystore file:
 $ keytool -importcert -alias "equifax-ca" -file EquifaxSecureGlobaleBusinessCA-1.crt -keystore truststore.jks -storepass test1234
 Owner: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US
 Issuer: CN=Equifax Secure Global eBusiness CA-1, O=Equifax Secure Inc., C=US
 Serial number: 1
 Valid from: Mon Jun 21 00:00:00 EDT 1999 until: Sun Jun 21 00:00:00 EDT 2020
 Certificate fingerprints:
 MD5:  8F:5D:77:06:27:C4:98:3C:5B:93:78:E7:D7:7D:9B:CC
 SHA1: 7E:78:4A:10:1C:82:65:CC:2D:E1:F1:6D:47:B4:40:CA:D9:0A:19:45
 Signature algorithm name: MD5withRSA
 Version: 3
 ...
 Trust this certificate? [no]:  yes
 Certificate was added to keystore
 
Now you want to use this truststore in your client:
 RestAssured.keystore("/truststore.jks", "test1234");
 
or
 given().keystore("/truststore.jks", "test1234"). ..
 

Parameters:
pathToJks - The path to the JKS
password - The store pass

addHeaders

public RequestSpecBuilder addHeaders(Map<String,String> headers)
Add headers to be sent with the request as Map.

Parameters:
headers - The Map containing the header names and their values to send with the request.
Returns:
The request specification builder

addHeader

public RequestSpecBuilder addHeader(String headerName,
                                    String headerValue)
Add a header to be sent with the request e.g:

Parameters:
headerName - The header name
headerValue - The header value
Returns:
The request specification builder

setContentType

public RequestSpecBuilder setContentType(groovyx.net.http.ContentType contentType)
Specify the content type of the request.

Parameters:
contentType - The content type of the request
Returns:
The request specification builder
See Also:
ContentType

setContentType

public RequestSpecBuilder setContentType(String contentType)
Specify the content type of the request as string.

Parameters:
contentType - The content type of the request
Returns:
The request specification builder

addMultiPart

public RequestSpecBuilder addMultiPart(File file)
Specify a file to upload to the server using multi-part form data uploading. It will assume that the control name is file and the content-type is application/octet-stream. If this is not what you want please use an overloaded method.

Parameters:
file - The file to upload
Returns:
The request specification

addMultiPart

public RequestSpecBuilder addMultiPart(String controlName,
                                       File file)
Specify a file to upload to the server using multi-part form data uploading with a specific control name. It will use the content-type application/octet-stream. If this is not what you want please use an overloaded method.

Parameters:
file - The file to upload
controlName - Defines the control name of the body part. In HTML this is the attribute name of the input tag.
Returns:
The request specification

addMultiPart

public RequestSpecBuilder addMultiPart(String controlName,
                                       File file,
                                       String mimeType)
Specify a file to upload to the server using multi-part form data uploading with a specific control name and content-type.

Parameters:
file - The file to upload
controlName - Defines the control name of the body part. In HTML this is the attribute name of the input tag.
mimeType - The content-type
Returns:
The request specification

addMultiPart

public RequestSpecBuilder addMultiPart(String controlName,
                                       String fileName,
                                       byte[] bytes)
Specify a byte-array to upload to the server using multi-part form data. It will use the content-type application/octet-stream. If this is not what you want please use an overloaded method.

Parameters:
controlName - Defines the control name of the body part. In HTML this is the attribute name of the input tag.
fileName - The name of the content you're uploading
bytes - The bytes you want to send
Returns:
The request specification

addMultiPart

public RequestSpecBuilder addMultiPart(String controlName,
                                       String fileName,
                                       byte[] bytes,
                                       String mimeType)
Specify a byte-array to upload to the server using multi-part form data.

Parameters:
controlName - Defines the control name of the body part. In HTML this is the attribute name of the input tag.
fileName - The name of the content you're uploading
bytes - The bytes you want to send
mimeType - The content-type
Returns:
The request specification

addMultiPart

public RequestSpecBuilder addMultiPart(String controlName,
                                       String fileName,
                                       InputStream stream)
Specify an inputstream to upload to the server using multi-part form data. It will use the content-type application/octet-stream. If this is not what you want please use an overloaded method.

Parameters:
controlName - Defines the control name of the body part. In HTML this is the attribute name of the input tag.
fileName - The name of the content you're uploading
stream - The stream you want to send
Returns:
The request specification

addMultiPart

public RequestSpecBuilder addMultiPart(String controlName,
                                       String fileName,
                                       InputStream stream,
                                       String mimeType)
Specify an inputstream to upload to the server using multi-part form data.

Parameters:
controlName - Defines the control name of the body part. In HTML this is the attribute name of the input tag.
fileName - The name of the content you're uploading
stream - The stream you want to send
mimeType - The content-type
Returns:
The request specification

addMultiPart

public RequestSpecBuilder addMultiPart(String controlName,
                                       String contentBody)
Specify a string to send to the server using multi-part form data. It will use the content-type text/plain. If this is not what you want please use an overloaded method.

Parameters:
controlName - Defines the control name of the body part. In HTML this is the attribute name of the input tag.
contentBody - The string to send
Returns:
The request specification

addMultiPart

public RequestSpecBuilder addMultiPart(String controlName,
                                       String contentBody,
                                       String mimeType)
Specify a string to send to the server using multi-part form data with a specific mime-type.

Parameters:
controlName - Defines the control name of the body part. In HTML this is the attribute name of the input tag.
contentBody - The string to send
mimeType - The mime-type
Returns:
The request specification

setAuthentication

public RequestSpecBuilder setAuthentication(AuthenticationScheme auth)
If you need to specify some credentials when performing a request.

Returns:
The request specification builder

setAuth

public RequestSpecBuilder setAuth(AuthenticationScheme auth)
A slightly short version of setAuthentication(com.jayway.restassured.authentication.AuthenticationScheme) )}.

Returns:
The request specification builder
See Also:
setAuthentication(com.jayway.restassured.authentication.AuthenticationScheme)

setPort

public RequestSpecBuilder setPort(int port)
Specify the port.

Parameters:
port - The port of URI
Returns:
The request specification builder

setUrlEncodingEnabled

public RequestSpecBuilder setUrlEncodingEnabled(boolean isEnabled)
Specifies if Rest Assured should url encode the URL automatically. Usually this is a recommended but in some cases e.g. the query parameters are already be encoded before you provide them to Rest Assured then it's useful to disable URL encoding.

Parameters:
isEnabled - Specify whether or not URL encoding should be enabled or disabled.
Returns:
The request specification builder

addRequestSpecification

public RequestSpecBuilder addRequestSpecification(RequestSpecification specification)
Merge this builder with settings from another specification. Note that the supplied specification can overwrite data in the current specification. The following settings are overwritten: The following settings are merged:

Parameters:
specification - The specification to add
Returns:
The request specification builder

setConfig

public RequestSpecBuilder setConfig(RestAssuredConfig config)
Define a configuration for redirection settings and http client parameters.

Parameters:
config - The configuration to use for this request. If null no config will be used.
Returns:
The request specification builder

build

public RequestSpecification build()
Build the request specification.

Returns:
The assembled request specification


Copyright © 2010-2011. All Rights Reserved.