Skip to content

Session

Session object for SOAP and REST services.

Action Summary

Action Description
DoRemoveParameter Remove one pre-defined parameter.
DoRemoveRequestHeader Remove one pre-defined request header by name.
GetCredential Returns HTTP Basic Authentication credentials (if any).
GetNewRequest Create new RESTService object with 'GET' method and specified url.
GetParameters Return common request parameters (array of `[{'Name':somename,'Value':somevalue},.
GetRequestHeaders Return common HTTP Headers applied to each REST or SOAP request (array of `[{'Name':somename,'Value':somevalue},.
GetRESTRequest Create new RESTService object with 'GET' method and specified url.
SetBaseUrl Enable URL replacement for all further requests.
SetCredential Sets HTTP Basic Authentication Credentials.
SetIgnoreStatus Set to true to prevent REST requests with non 200 status code from failing the test.
SetParameter Sets common request parameter.
SetParameters Sets common request parameters.
SetRequestHeader Sets common request header.
SetRequestHeaders Sets common HTTP Headers applied to each REST or SOAP request.
SetUrl Deprecated.

Action Detail

DoRemoveParameter

Remove one pre-defined parameter. Requires Rapise 6.6+

DoRemoveParameter(name) 

Parameters:

Name Type Description
name string Parameter name

DoRemoveRequestHeader

Remove one pre-defined request header by name. Requires Rapise 6.6+

DoRemoveRequestHeader(name) 

Parameters:

Name Type Description
name string Header name

GetCredential

Returns HTTP Basic Authentication credentials (if any).

GetCredential() 

GetNewRequest

Create new RESTService object with 'GET' method and specified url.

GetNewRequest(url, name) 

Parameters:

Name Type Description
url string Request URL
name string Request name used to display in the report
Optional.

GetParameters

Return common request parameters (array of [{'Name':somename,'Value':somevalue},...])

GetParameters() 

GetRequestHeaders

Return common HTTP Headers applied to each REST or SOAP request (array of [{'Name':somename,'Value':somevalue},...])

GetRequestHeaders() 

GetRESTRequest

Create new RESTService object with 'GET' method and specified url.

GetRESTRequest(defNameOrPath, id) 

Parameters:

Name Type Description
defNameOrPath string Path to the .rest definition file
id string Name of the request (as specified in the .rest definition file)

SetBaseUrl

Enable URL replacement for all further requests. If request URL starts with oldUrl then replace the beginning with newUrl. Requires Rapise 6.6+

SetBaseUrl(oldUrl, newUrl) 

Parameters:

Name Type Description
oldUrl string URL to find
newUrl string new URL to use instead of oldUrl

SetCredential

Sets HTTP Basic Authentication Credentials. Sample code:

var credential = {};
credential.UserName = "fredbloggs";
credential.Password = "MyPassword";
SeS("Operation_Name").SetCredential(credential);

Another way is to pass user name and password as first and second parameter respectively, e.g. SeS("Operation_Name").SetCredential("fredbloggs", "MyPassword");

SetCredential(value, value2) 

Parameters:

Name Type Description
value string | object User name or full object with credentials.
value2 string Password string. Do not set this parameter if you pass object as the first one.

SetIgnoreStatus

Set to true to prevent REST requests with non 200 status code from failing the test. It would <req>.DoExecute() will just return true/false but the line in report will always be marked as Passed.

SetIgnoreStatus(ignore) 

Parameters:

Name Type Description
ignore boolean true to ignore status code

SetParameter

Sets common request parameter. This parameter will be applied to all further REST and SOAP requests.

SetParameter(name, value) 

Parameters:

Name Type Description
name string Parameter name
value string Parameter value

SetParameters

Sets common request parameters. These parameters will be applied to all further REST and SOAP requests. Accepts one of:

  • Full array of parameters: [{'Name':somename,'Value':somevalue},...]
  • Single parameter as object: {'Name':somename,'Value':somevalue}
  • Single parameter as 2 input parameters: Session.SetParameters(name,value).
SetParameters(requestParam, optValueVal) 

Parameters:

Name Type Description
requestParam object Parameters or single parameter.
optValueVal string Parameter value, when specified. If this value is set, then 'requestParam' should be a string and method signature will be Session.SetParameters('name','value')
Optional.

SetRequestHeader

Sets common request header. This header will be applied to all further REST and SOAP requests.

SetRequestHeader(name, value) 

Parameters:

Name Type Description
name string HTTP header name
value string HTTP header value

SetRequestHeaders

Sets common HTTP Headers applied to each REST or SOAP request. Accepts one of:

  • Full array of headers: [{'Name':somename,'Value':somevalue},...]
  • Single header as object: {'Name':somename,'Value':somevalue}
  • Single header as 2 input parameters: Session.SetRequestHeaders(name, value)
SetRequestHeaders(requestParam, optValueVal) 

Parameters:

Name Type Description
requestParam object Header(s) object or single header name.
optValueVal string Header value, when specified. If this value is set, then 'requestParam' should be a string and method signature will be Session.SetRequestHeaders('name','value')
Optional.

SetUrl

Deprecated. Same as SetBaseUrl.

SetUrl(oldUrl, newUrl) 

Parameters:

Name Type Description
oldUrl string URL to find
newUrl string new URL to use instead of oldUrl