# DeleteRequest

## Overview

The `DeleteRequest` object facilitates the creation and execution of HTTP DELETE requests, offering configurable parameters, headers, and authentication options. It supports both synchronous and asynchronous workflows while accommodating authentication needs like preemptive authentication and domain-based mechanisms.

Asynchronous execution options enable efficient response and error handling through callbacks, while support for enforcing formats such as `multipart/form-data` enhances compatibility with various server requirements.

## Methods Summarized

| Type                                                  | Name                                                                                                                                                                                                                                                 | Summary                                                                                                                                                                                                                                                                                                   |
| ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Boolean](../../../servoycore/dev-api/js-lib/boolean) | [addFile(parameterName, jsFile)](#addfile-parametername-jsfile)                                                                                                                                                                                      | Add a file to the post; it will try to get the correct mime type from the file name or the first bytes.                                                                                                                                                                                                   |
| [Boolean](../../../servoycore/dev-api/js-lib/boolean) | [addFile(parameterName, jsFile, mimeType)](#addfile-parametername-jsfile-mimetype)                                                                                                                                                                   | Add a file to the post with a given mime type; could also be used to force the default 'application/octet-stream' on it, because this plugin will try to guess the correct mime type for the given file otherwise (based on the name or the bytes).                                                       |
| [Boolean](../../../servoycore/dev-api/js-lib/boolean) | [addFile(parameterName, fileName, jsFile)](#addfile-parametername-filename-jsfile)                                                                                                                                                                   | Add a file to the post; it will try to get the correct mime type from the file name or the first bytes.                                                                                                                                                                                                   |
| [Boolean](../../../servoycore/dev-api/js-lib/boolean) | [addFile(parameterName, fileName, jsFile, mimeType)](#addfile-parametername-filename-jsfile-mimetype)                                                                                                                                                | Add a file to the post with a given mime type; could also be used to force the default 'application/octet-stream' on it, because this plugin will try to guess the correct mime type for the given file otherwise (based on the name or the bytes).                                                       |
| [Boolean](../../../servoycore/dev-api/js-lib/boolean) | [addFile(parameterName, fileName, fileLocation)](#addfile-parametername-filename-filelocation)                                                                                                                                                       | Add a file to the post; it will try to get the correct mime type from the file name or the first bytes.                                                                                                                                                                                                   |
| [Boolean](../../../servoycore/dev-api/js-lib/boolean) | [addFile(parameterName, fileName, fileLocation, mimeType)](#addfile-parametername-filename-filelocation-mimetype)                                                                                                                                    | Add a file to the post with a given mime type; could also be used to force the default 'application/octet-stream' on it, because this plugin will try to guess the correct mime type for the given file otherwise (based on the name or the bytes).                                                       |
| [Boolean](../../../servoycore/dev-api/js-lib/boolean) | [addHeader(headerName, value)](#addheader-headername-value)                                                                                                                                                                                          | Add a header to the request.                                                                                                                                                                                                                                                                              |
| [Boolean](../../../servoycore/dev-api/js-lib/boolean) | [addParameter(name, value)](#addparameter-name-value)                                                                                                                                                                                                | Add a parameter to the post.                                                                                                                                                                                                                                                                              |
| [Boolean](../../../servoycore/dev-api/js-lib/boolean) | [addParameter(name, value, mimeType)](#addparameter-name-value-mimetype)                                                                                                                                                                             | Add a parameter to the post.                                                                                                                                                                                                                                                                              |
| [Promise](../../../servoycore/dev-api/js-lib/promise) | [executeAsyncRequest()](#executeasyncrequest)                                                                                                                                                                                                        | Execute the request method asynchronous a Promise is returned which will be resolved or rejected when the request is completed or failed.                                                                                                                                                                 |
| [Promise](../../../servoycore/dev-api/js-lib/promise) | [executeAsyncRequest({String})](#executeasyncrequest-{string})                                                                                                                                                                                       | Execute the request method asynchronous a Promise is returned which will be resolved or rejected when the request is completed or failed.                                                                                                                                                                 |
| [Promise](../../../servoycore/dev-api/js-lib/promise) | [executeAsyncRequest({String})](#executeasyncrequest-{string})                                                                                                                                                                                       | Execute the request method asynchronous a Promise is returned which will be resolved or rejected when the request is completed or failed.                                                                                                                                                                 |
| void                                                  | [executeAsyncRequest(username, password, workstation, domain, successCallbackMethod, errorCallbackMethod)](#executeasyncrequest-username-password-workstation-domain-successcallbackmethod-errorcallbackmethod)                                      | Execute the request method asynchronous.                                                                                                                                                                                                                                                                  |
| void                                                  | [executeAsyncRequest(username, password, workstation, domain, successCallbackMethod, errorCallbackMethod, callbackExtraArgs)](#executeasyncrequest-username-password-workstation-domain-successcallbackmethod-errorcallbackmethod-callbackextraargs) | Execute the request method asynchronous using windows authentication.                                                                                                                                                                                                                                     |
| void                                                  | [executeAsyncRequest(username, password, successCallbackMethod, errorCallbackMethod)](#executeasyncrequest-username-password-successcallbackmethod-errorcallbackmethod)                                                                              | Execute the request method asynchronous.                                                                                                                                                                                                                                                                  |
| void                                                  | [executeAsyncRequest(username, password, successCallbackMethod, errorCallbackMethod, callbackExtraArgs)](#executeasyncrequest-username-password-successcallbackmethod-errorcallbackmethod-callbackextraargs)                                         | Execute the request method asynchronous using windows authentication.                                                                                                                                                                                                                                     |
| void                                                  | [executeAsyncRequest(successCallbackMethod, errorCallbackMethod)](#executeasyncrequest-successcallbackmethod-errorcallbackmethod)                                                                                                                    | Execute the request method asynchronous.                                                                                                                                                                                                                                                                  |
| void                                                  | [executeAsyncRequest(successCallbackMethod, errorCallbackMethod, callbackExtraArgs)](#executeasyncrequest-successcallbackmethod-errorcallbackmethod-callbackextraargs)                                                                               | Execute the request method asynchronous using windows authentication.                                                                                                                                                                                                                                     |
| [Response](response)                                  | [executeRequest()](#executerequest)                                                                                                                                                                                                                  | Execute the request method.                                                                                                                                                                                                                                                                               |
| [Response](response)                                  | [executeRequest(userName, password)](#executerequest-username-password)                                                                                                                                                                              | Execute the request method.                                                                                                                                                                                                                                                                               |
| [Response](response)                                  | [executeRequest(userName, password, workstation, domain)](#executerequest-username-password-workstation-domain)                                                                                                                                      | Execute a request method using windows authentication.                                                                                                                                                                                                                                                    |
| void                                                  | [forceMultipart(forceMultipart)](#forcemultipart-forcemultipart)                                                                                                                                                                                     | Force this request to prepare a "Content-Type: multipart/form-data" formatted message even if only one file or only a number of parameter were added to it.                                                                                                                                               |
| [String](../../../servoycore/dev-api/js-lib/string)   | [getContentType()](#getcontenttype)                                                                                                                                                                                                                  | Get the content type of the request body.                                                                                                                                                                                                                                                                 |
| [Object](../../../servoycore/dev-api/js-lib/object)   | [getHeaders()](#getheaders)                                                                                                                                                                                                                          | This returns a Object with header names as keys and arrays of values as values.                                                                                                                                                                                                                           |
| [String](../../../servoycore/dev-api/js-lib/string)   | [getHttpBody()](#gethttpbody)                                                                                                                                                                                                                        | Get the raw body content of the request.                                                                                                                                                                                                                                                                  |
| [String](../../../servoycore/dev-api/js-lib/string)   | [getHttpMethod()](#gethttpmethod)                                                                                                                                                                                                                    | Get the HTTP method of the request.                                                                                                                                                                                                                                                                       |
| [Object](../../../servoycore/dev-api/js-lib/object)   | [getParameters()](#getparameters)                                                                                                                                                                                                                    | Get form parameters of the request.                                                                                                                                                                                                                                                                       |
| [Object](../../../servoycore/dev-api/js-lib/object)   | [getQueryParameters()](#getqueryparameters)                                                                                                                                                                                                          | Get query parameters from the request URL.                                                                                                                                                                                                                                                                |
| [Object](../../../servoycore/dev-api/js-lib/object)   | [getRequestConfig()](#getrequestconfig)                                                                                                                                                                                                              | Get the Apache RequestConfig for this request.                                                                                                                                                                                                                                                            |
| [Number](../../../servoycore/dev-api/js-lib/number)   | [getTimeout()](#gettimeout)                                                                                                                                                                                                                          | Get the configured response timeout in milliseconds.                                                                                                                                                                                                                                                      |
| [String](../../../servoycore/dev-api/js-lib/string)   | [getUrl()](#geturl)                                                                                                                                                                                                                                  | Get the URL of the request.                                                                                                                                                                                                                                                                               |
| void                                                  | [setBodyContent(content)](#setbodycontent-content)                                                                                                                                                                                                   | Set the body of the request.                                                                                                                                                                                                                                                                              |
| void                                                  | [setBodyContent(content, mimeType)](#setbodycontent-content-mimetype)                                                                                                                                                                                | Set the body of the request and content mime type.                                                                                                                                                                                                                                                        |
| void                                                  | [setCharset(charset)](#setcharset-charset)                                                                                                                                                                                                           | Set the charset used when posting.                                                                                                                                                                                                                                                                        |
| void                                                  | [usePreemptiveAuthentication(b)](#usepreemptiveauthentication-b)                                                                                                                                                                                     | Whatever to use preemptive authentication (sending the credentials in the header, avoiding the server request to the client - useful when uploading files, as some http servers would cancel the first request from the client, if too big, as the authentication request to the client was not yet sent) |

## Methods Detailed

### addFile(parameterName, jsFile)

Add a file to the post; it will try to get the correct mime type from the file name or the first bytes.

If you add a single file then this will be a single file (so not a multi-part) post. If you want/need multi-part then you have to either add multiple files or both a file and one or more parameters using addParameter(...).

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **parameterName** ;
* [Object](../../../servoycore/dev-api/js-lib/object) **jsFile** ;

**Returns:** [Boolean](../../../servoycore/dev-api/js-lib/boolean) true if the JSFile was successfully added to the request, false otherwise.

**Sample**

```js
poster.addFile('myFileParamName','manual.doc','c:/temp/manual_01a.doc')
poster.addFile(null,'postXml.xml','c:/temp/postXml.xml') // sets the xml to post

var f = plugins.file.convertToJSFile('./somefile02.txt')
if (f && f.exists()) poster.addFile('myTxtFileParamName','somefile.txt', f)

f = plugins.file.convertToJSFile('./anotherfile_v2b.txt')
if (f && f.exists()) poster.addFile('myOtherTxtFileParamName', f)
```

### addFile(parameterName, jsFile, mimeType)

Add a file to the post with a given mime type; could also be used to force the default 'application/octet-stream' on it, because this plugin will try to guess the correct mime type for the given file otherwise (based on the name or the bytes).

If you add a single file then this will be a single file (so not a multi-part) post. If you want/need multi-part then you have to either add multiple files or both a file and one or more parameters using addParameter(...).

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **parameterName** ;
* [Object](../../../servoycore/dev-api/js-lib/object) **jsFile** ;
* [String](../../../servoycore/dev-api/js-lib/string) **mimeType** The mime type that must be used could be the real default ('application/octet-stream') if the files one (by name or by its first bytes) is not good.

**Returns:** [Boolean](../../../servoycore/dev-api/js-lib/boolean) true if the JSFile with the specified mime type was successfully added, false otherwise.

**Sample**

```js
poster.addFile('myFileParamName','manual.doc','c:/temp/manual_01a.doc', 'application/msword')
poster.addFile(null,'postXml.xml','c:/temp/postXml.xml', 'text/xml') // sets the xml to post

var f = plugins.file.convertToJSFile('./somefile02.txt')
if (f && f.exists()) poster.addFile('myTxtFileParamName','somefile.txt', f, 'text/plain')

f = plugins.file.convertToJSFile('./anotherfile_v2b.txt')
if (f && f.exists()) poster.addFile('myOtherTxtFileParamName', f, 'text/plain')
```

### addFile(parameterName, fileName, jsFile)

Add a file to the post; it will try to get the correct mime type from the file name or the first bytes.

If you add a single file then this will be a single file (so not a multi-part) post. If you want/need multi-part then you have to either add multiple files or both a file and one or more parameters using addParameter(...).

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **parameterName** ;
* [String](../../../servoycore/dev-api/js-lib/string) **fileName** ;
* [Object](../../../servoycore/dev-api/js-lib/object) **jsFile** ;

**Returns:** [Boolean](../../../servoycore/dev-api/js-lib/boolean) true if the specified file was successfully added to the request, false otherwise.

**Sample**

```js
poster.addFile('myFileParamName','manual.doc','c:/temp/manual_01a.doc')
poster.addFile(null,'postXml.xml','c:/temp/postXml.xml') // sets the xml to post

var f = plugins.file.convertToJSFile('./somefile02.txt')
if (f && f.exists()) poster.addFile('myTxtFileParamName','somefile.txt', f)

f = plugins.file.convertToJSFile('./anotherfile_v2b.txt')
if (f && f.exists()) poster.addFile('myOtherTxtFileParamName', f)
```

### addFile(parameterName, fileName, jsFile, mimeType)

Add a file to the post with a given mime type; could also be used to force the default 'application/octet-stream' on it, because this plugin will try to guess the correct mime type for the given file otherwise (based on the name or the bytes).

If you add a single file then this will be a single file (so not a multi-part) post. If you want/need multi-part then you have to either add multiple files or both a file and one or more parameters using addParameter(...).

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **parameterName** ;
* [String](../../../servoycore/dev-api/js-lib/string) **fileName** ;
* [Object](../../../servoycore/dev-api/js-lib/object) **jsFile** ;
* [String](../../../servoycore/dev-api/js-lib/string) **mimeType** The mime type that must be used could be the real default ('application/octet-stream') if the files one (by name or by its first bytes) is not good.

**Returns:** [Boolean](../../../servoycore/dev-api/js-lib/boolean) true if the file with the given parameters and mime type was successfully added, false otherwise.

**Sample**

```js
poster.addFile('myFileParamName','manual.doc','c:/temp/manual_01a.doc', 'application/msword')
poster.addFile(null,'postXml.xml','c:/temp/postXml.xml', 'text/xml') // sets the xml to post

var f = plugins.file.convertToJSFile('./somefile02.txt')
if (f && f.exists()) poster.addFile('myTxtFileParamName','somefile.txt', f, 'text/plain')

f = plugins.file.convertToJSFile('./anotherfile_v2b.txt')
if (f && f.exists()) poster.addFile('myOtherTxtFileParamName', f, 'text/plain')
```

### addFile(parameterName, fileName, fileLocation)

Add a file to the post; it will try to get the correct mime type from the file name or the first bytes.

If you add a single file then this will be a single file (so not a multi-part) post. If you want/need multi-part then you have to either add multiple files or a file and at least a parameter via addParameter(...).

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **parameterName** ;
* [String](../../../servoycore/dev-api/js-lib/string) **fileName** ;
* [String](../../../servoycore/dev-api/js-lib/string) **fileLocation** ;

**Returns:** [Boolean](../../../servoycore/dev-api/js-lib/boolean) true if the file was successfully added to the request, false otherwise.

**Sample**

```js
poster.addFile('myFileParamName','manual.doc','c:/temp/manual_01a.doc')
poster.addFile(null,'postXml.xml','c:/temp/postXml.xml') // sets the xml to post

var f = plugins.file.convertToJSFile('./somefile02.txt')
if (f && f.exists()) poster.addFile('myTxtFileParamName','somefile.txt', f)

f = plugins.file.convertToJSFile('./anotherfile_v2b.txt')
if (f && f.exists()) poster.addFile('myOtherTxtFileParamName', f)
```

### addFile(parameterName, fileName, fileLocation, mimeType)

Add a file to the post with a given mime type; could also be used to force the default 'application/octet-stream' on it, because this plugin will try to guess the correct mime type for the given file otherwise (based on the name or the bytes).

If you add a single file then this will be a single file (so not a multi-part) post. If you want/need multi-part then you have to either add multiple files or both a file and one or more parameters using addParameter(...).

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **parameterName** ;
* [String](../../../servoycore/dev-api/js-lib/string) **fileName** ;
* [String](../../../servoycore/dev-api/js-lib/string) **fileLocation** ;
* [String](../../../servoycore/dev-api/js-lib/string) **mimeType** The mime type that must be used could be the real default ('application/octet-stream') if the files one (by name or by its first bytes) is not good.

**Returns:** [Boolean](../../../servoycore/dev-api/js-lib/boolean) true if the file with the specified mime type was successfully added, false otherwise.

**Sample**

```js
poster.addFile('myFileParamName','manual.doc','c:/temp/manual_01a.doc', 'application/msword')
poster.addFile(null,'postXml.xml','c:/temp/postXml.xml', 'text/xml') // sets the xml to post

var f = plugins.file.convertToJSFile('./somefile02.txt')
if (f && f.exists()) poster.addFile('myTxtFileParamName','somefile.txt', f, 'text/plain')

f = plugins.file.convertToJSFile('./anotherfile_v2b.txt')
if (f && f.exists()) poster.addFile('myOtherTxtFileParamName', f, 'text/plain')
```

### addHeader(headerName, value)

Add a header to the request.

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **headerName** ;
* [String](../../../servoycore/dev-api/js-lib/string) **value** ;

**Returns:** [Boolean](../../../servoycore/dev-api/js-lib/boolean) A boolean indicating whether the header was successfully added to the request.

**Sample**

```js
method.addHeader('Content-type','text/xml; charset=ISO-8859-1')
```

### addParameter(name, value)

Add a parameter to the post.

If there is also at least one file added to this request using addFile(...) then a multi-part post will be generated.

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **name** ;
* [String](../../../servoycore/dev-api/js-lib/string) **value** ;

**Returns:** [Boolean](../../../servoycore/dev-api/js-lib/boolean) true if the parameter was successfully added, false otherwise.

**Sample**

```js
poster.addParameter('name','value')
poster.addParameter(null,'value') //sets the content to post
```

### addParameter(name, value, mimeType)

Add a parameter to the post.

If there is also at least one file added to this request using addFile(...) then a multi-part post will be generated. The multipart element will also contain content-type header, set from mimeType and charset. By default, this header is not present.

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **name** ;
* [String](../../../servoycore/dev-api/js-lib/string) **value** ;
* [String](../../../servoycore/dev-api/js-lib/string) **mimeType** ;

**Returns:** [Boolean](../../../servoycore/dev-api/js-lib/boolean) true if the parameter with the specified mime type was successfully added, false otherwise.

**Sample**

```js
poster.addParameter('name','value','text/plain')
```

### executeAsyncRequest()

Execute the request method asynchronous a Promise is returned which will be resolved or rejected when the request is completed or failed.

This Response can be a response with a different status code then just 200, it could also be 500, which is still a valid response from the server.\
So you need to test the Reponse.getStatusCode() for that to know if everything did go OK.\
If no response is received (request errors out), the Promise is rejected with exception message as the value.

You can use Promise.all(\[promise1, promise2, promise3]) to wait for multiple promises to complete.\
A shortcut for this would be to use httpClient.executeRequest(requestArray) that returns 1 promise that is called when all of them are done.

**Returns:** [Promise](../../../servoycore/dev-api/js-lib/promise) A Promise that resolves with a Response object upon request completion or rejects with an error message if the request fails.

**Sample**

```js
request.executeAsyncRequest().then(response => { // handle the response }).catch(errorMessage => { // handle the error });})
```

### executeAsyncRequest({String})

Execute the request method asynchronous a Promise is returned which will be resolved or rejected when the request is completed or failed.

This Response can be a response with a different status code then just 200, it could also be 500, which is still a valid response from the server.\
So you need to test the Reponse.getStatusCode() for that to know if everything did go OK.\
If no response is received (request errors out), the Promise is rejected with exception message as the value.

You can use Promise.all(\[promise1, promise2, promise3]) to wait for multiple promises to complete.\
A shortcut for this would be to use httpClient.executeRequest(requestArray) that returns 1 promise that is called when all of them are done.

**Parameters**

* [Object](../../../servoycore/dev-api/js-lib/object) **{String}** password The password used for authentication.

**Returns:** [Promise](../../../servoycore/dev-api/js-lib/promise) A Promise that resolves with a Response object upon request completion or rejects with an error message if the request fails.

**Sample**

```js
request.executeAsyncRequest().then(response => { // handle the response }).catch(errorMessage => { // handle the error });})
```

### executeAsyncRequest({String})

Execute the request method asynchronous a Promise is returned which will be resolved or rejected when the request is completed or failed.

This Response can be a response with a different status code then just 200, it could also be 500, which is still a valid response from the server.\
So you need to test the Reponse.getStatusCode() for that to know if everything did go OK.\
If no response is received (request errors out), the Promise is rejected with exception message as the value.

You can use Promise.all(\[promise1, promise2, promise3]) to wait for multiple promises to complete.\
A shortcut for this would be to use httpClient.executeRequest(requestArray) that returns 1 promise that is called when all of them are done.

**Parameters**

* [Object](../../../servoycore/dev-api/js-lib/object) **{String}** domain The domain to authenticate within.

**Returns:** [Promise](../../../servoycore/dev-api/js-lib/promise) A Promise that resolves with a Response object upon request completion or rejects with an error message if the request fails.

**Sample**

```js
request.executeAsyncRequest().then(response => { // handle the response }).catch(errorMessage => { // handle the error });})
```

### executeAsyncRequest(username, password, workstation, domain, successCallbackMethod, errorCallbackMethod)

Execute the request method asynchronous. Success callback method will be called when response is received.\
Response is sent as parameter in callback.\
This Response can be a response with a different status code then just 200, it could also be 500, which is still a valid response from the server, this won't go into the error callback.\
So you need to test the Reponse.getStatusCode() for that to know if everything did go OK.\
If no response is received (request errors out), the errorCallbackMethod is called with exception message as parameter.

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **username** the user name
* [String](../../../servoycore/dev-api/js-lib/string) **password** the password
* [String](../../../servoycore/dev-api/js-lib/string) **workstation** The workstation the authentication request is originating from.
* [String](../../../servoycore/dev-api/js-lib/string) **domain** The domain to authenticate within.
* [Function](../../../servoycore/dev-api/js-lib/function) **successCallbackMethod** callbackMethod to be called after response is received
* [Function](../../../servoycore/dev-api/js-lib/function) **errorCallbackMethod** callbackMethod to be called if request errors out

**Returns:** void

**Sample**

```js
method.executeAsyncRequest('username','password','mycomputername','domain',globals.successCallback,globals.errorCallback)
```

### executeAsyncRequest(username, password, workstation, domain, successCallbackMethod, errorCallbackMethod, callbackExtraArgs)

Execute the request method asynchronous using windows authentication.\
Success callback method will be called when response is received. Response is sent as parameter in callback followed by any 'callbackExtraArgs' that were given.\
This Response can be a response with a different status code then just 200, it could also be 500, which is still a valid response from the server, this won't go into the error callback.\
So you need to test the Reponse.getStatusCode() for that to know if everything did go OK.\
If no response is received (request errors out, network errors), the errorCallbackMethod is called with exception message as parameter followed by any 'callbackExtraArgs' that were given.

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **username** the user name
* [String](../../../servoycore/dev-api/js-lib/string) **password** the password
* [String](../../../servoycore/dev-api/js-lib/string) **workstation** The workstation the authentication request is originating from.
* [String](../../../servoycore/dev-api/js-lib/string) **domain** The domain to authenticate within.
* [Function](../../../servoycore/dev-api/js-lib/function) **successCallbackMethod** callbackMethod to be called after response is received
* [Function](../../../servoycore/dev-api/js-lib/function) **errorCallbackMethod** callbackMethod to be called if request errors out
* [Array](../../../servoycore/dev-api/js-lib/array) **callbackExtraArgs** extra arguments that will be passed to the callback methods; can be used to identify from which request the response arrived when using the same callback method for multiple requests. Please use only simple JSON arguments (primitive types or array/objects of primitive types)

**Returns:** void

**Sample**

```js
method.executeAsyncRequest('username','password','mycomputername','domain',globals.successCallback,globals.errorCallback, [callIDInt])
```

### executeAsyncRequest(username, password, successCallbackMethod, errorCallbackMethod)

Execute the request method asynchronous. Success callback method will be called when response is received.\
Response is sent as parameter in callback.\
This Response can be a response with a different status code then just 200, it could also be 500, which is still a valid response from the server, this won't go into the error callback.\
So you need to test the Reponse.getStatusCode() for that to know if everything did go OK.\
If no response is received (request errors out), the errorCallbackMethod is called with exception message as parameter.

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **username** the user name
* [String](../../../servoycore/dev-api/js-lib/string) **password** the password
* [Function](../../../servoycore/dev-api/js-lib/function) **successCallbackMethod** callbackMethod to be called after response is received
* [Function](../../../servoycore/dev-api/js-lib/function) **errorCallbackMethod** callbackMethod to be called if request errors out

**Returns:** void

**Sample**

```js
method.executeAsyncRequest(globals.successCallback,globals.errorCallback)
```

### executeAsyncRequest(username, password, successCallbackMethod, errorCallbackMethod, callbackExtraArgs)

Execute the request method asynchronous using windows authentication.\
Success callback method will be called when response is received. Response is sent as parameter in callback followed by any 'callbackExtraArgs' that were given.\
This Response can be a response with a different status code then just 200, it could also be 500, which is still a valid response from the server, this won't go into the error callback.\
So you need to test the Reponse.getStatusCode() for that to know if everything did go OK.\
If no response is received (request errors out, network errors), the errorCallbackMethod is called with exception message as parameter followed by any 'callbackExtraArgs' that were given.

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **username** the user name
* [String](../../../servoycore/dev-api/js-lib/string) **password** the password
* [Function](../../../servoycore/dev-api/js-lib/function) **successCallbackMethod** callbackMethod to be called after response is received
* [Function](../../../servoycore/dev-api/js-lib/function) **errorCallbackMethod** callbackMethod to be called if request errors out
* [Array](../../../servoycore/dev-api/js-lib/array) **callbackExtraArgs** extra arguments that will be passed to the callback methods; can be used to identify from which request the response arrived when using the same callback method for multiple requests. Please use only simple JSON arguments (primitive types or array/objects of primitive types)

**Returns:** void

**Sample**

```js
method.executeAsyncRequest(globals.successCallback,globals.errorCallback, [callIDInt])
```

### executeAsyncRequest(successCallbackMethod, errorCallbackMethod)

Execute the request method asynchronous. Success callback method will be called when response is received.\
Response is sent as parameter in callback.\
This Response can be a response with a different status code then just 200, it could also be 500, which is still a valid response from the server, this won't go into the error callback.\
So you need to test the Reponse.getStatusCode() for that to know if everything did go OK.\
If no response is received (request errors out), the errorCallbackMethod is called with exception message as parameter.

**Parameters**

* [Function](../../../servoycore/dev-api/js-lib/function) **successCallbackMethod** callbackMethod to be called after response is received
* [Function](../../../servoycore/dev-api/js-lib/function) **errorCallbackMethod** callbackMethod to be called if request errors out

**Returns:** void

**Sample**

```js
method.executeAsyncRequest(globals.successCallback,globals.errorCallback)
```

### executeAsyncRequest(successCallbackMethod, errorCallbackMethod, callbackExtraArgs)

Execute the request method asynchronous using windows authentication.\
Success callback method will be called when response is received. Response is sent as parameter in callback followed by any 'callbackExtraArgs' that were given.\
This Response can be a response with a different status code then just 200, it could also be 500, which is still a valid response from the server, this won't go into the error callback.\
So you need to test the Reponse.getStatusCode() for that to know if everything did go OK.\
If no response is received (request errors out, network errors), the errorCallbackMethod is called with exception message as parameter followed by any 'callbackExtraArgs' that were given.

**Parameters**

* [Function](../../../servoycore/dev-api/js-lib/function) **successCallbackMethod** callbackMethod to be called after response is received
* [Function](../../../servoycore/dev-api/js-lib/function) **errorCallbackMethod** callbackMethod to be called if request errors out
* [Array](../../../servoycore/dev-api/js-lib/array) **callbackExtraArgs** extra arguments that will be passed to the callback methods; can be used to identify from which request the response arrived when using the same callback method for multiple requests. Please use only simple JSON arguments (primitive types or array/objects of primitive types)

**Returns:** void

**Sample**

```js
method.executeAsyncRequest(globals.successCallback,globals.errorCallback, [callIDInt])
```

### executeRequest()

Execute the request method.

**Returns:** [Response](response) A Response object containing the result of the executed HTTP request.

**Sample**

```js
var response = method.executeRequest()

To be able to reuse the client, the response must be
closed if the content is not read via getResponseBody
 or getMediaData:

response.close()
```

### executeRequest(userName, password)

Execute the request method.

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **userName** the user name
* [String](../../../servoycore/dev-api/js-lib/string) **password** the password

**Returns:** [Response](response) A Response object containing the result of the HTTP request, authenticated with the provided username and password.

**Sample**

```js
var response = method.executeRequest()

To be able to reuse the client, the response must be
closed if the content is not read via getResponseBody
 or getMediaData:

response.close()
```

### executeRequest(userName, password, workstation, domain)

Execute a request method using windows authentication.

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **userName** the user name
* [String](../../../servoycore/dev-api/js-lib/string) **password** the password
* [String](../../../servoycore/dev-api/js-lib/string) **workstation** The workstation the authentication request is originating from.
* [String](../../../servoycore/dev-api/js-lib/string) **domain** The domain to authenticate within.

**Returns:** [Response](response) A Response object containing the result of the HTTP request, authenticated using Windows authentication with the provided credentials.

**Sample**

```js
var response = method.executeRequest('username','password','mycomputername','domain');
```

### forceMultipart(forceMultipart)

Force this request to prepare a "Content-Type: multipart/form-data" formatted message even if only one file or only a number of parameter were added to it.

It is useful because some servers require this (they only support multipart - even if you don't need to send multiple things). Before Servoy 2021.03 you could force it to send multipart by adding a dummy parameter together with a single file (or the other way around) - if the server didn't object to that dummy content...

Default value: false. (if you only add one file or only parameters it will not generate a multipart request)

**Parameters**

* [Boolean](../../../servoycore/dev-api/js-lib/boolean) **forceMultipart** if true, this request will send a multipart/form-data message even if you only add one file or only parameters. If false (default) it will send multipart only in case of multiple files or one file plus at least one parameter.

**Returns:** void

### getContentType()

Get the content type of the request body.

**Returns:** [String](../../../servoycore/dev-api/js-lib/string) The MIME type of the body.

### getHeaders()

This returns a Object with header names as keys and arrays of values as values.

**Returns:** [Object](../../../servoycore/dev-api/js-lib/object) An Object with "name" > "value"

### getHttpBody()

Get the raw body content of the request.

**Returns:** [String](../../../servoycore/dev-api/js-lib/string) The body content, or null if none.

### getHttpMethod()

Get the HTTP method of the request.

**Returns:** [String](../../../servoycore/dev-api/js-lib/string) The HTTP method (e.g., "GET", "POST").

### getParameters()

Get form parameters of the request.

**Returns:** [Object](../../../servoycore/dev-api/js-lib/object) A map of parameter names to values.

### getQueryParameters()

Get query parameters from the request URL.

**Returns:** [Object](../../../servoycore/dev-api/js-lib/object) A map of parameter names to arrays of values.

### getRequestConfig()

Get the Apache RequestConfig for this request.

**Returns:** [Object](../../../servoycore/dev-api/js-lib/object) The built RequestConfig.

### getTimeout()

Get the configured response timeout in milliseconds.

**Returns:** [Number](../../../servoycore/dev-api/js-lib/number) Timeout in ms, or –1 if none.

### getUrl()

Get the URL of the request.

**Returns:** [String](../../../servoycore/dev-api/js-lib/string) The request URL.

### setBodyContent(content)

Set the body of the request.

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **content** ;

**Returns:** void

**Sample**

```js
method.setBodyContent(content)
```

### setBodyContent(content, mimeType)

Set the body of the request and content mime type.

**Parameters**

* [String](../../../servoycore/dev-api/js-lib/string) **content** ;
* [String](../../../servoycore/dev-api/js-lib/string) **mimeType** ;

**Returns:** void

**Sample**

```js
method.setBodyContent(content, 'text/xml')
```

### setCharset(charset)

Set the charset used when posting. If this is null or not called it will use the default charset (UTF-8).

**Parameters**

* [Object](../../../servoycore/dev-api/js-lib/object) **charset** ;

**Returns:** void

**Sample**

```js
var client = plugins.http.createNewHttpClient();
var poster = client.createPostRequest('https://twitter.com/statuses/update.json');
poster.addParameter('status',scopes.globals.textToPost);
poster.addParameter('source','Test Source');
poster.setCharset('UTF-8');
var httpCode = poster.executeRequest(scopes.globals.twitterUserName, scopes.globals.twitterPassword).getStatusCode() // httpCode 200 is ok
```

### usePreemptiveAuthentication(b)

Whatever to use preemptive authentication (sending the credentials in the header, avoiding the server request to the client - useful when uploading files, as some http servers would cancel the first request from the client, if too big, as the authentication request to the client was not yet sent)

**Parameters**

* [Boolean](../../../servoycore/dev-api/js-lib/boolean) **b** ;

**Returns:** void

***
