If you are using oxygen.conf.js, http module must be added.
modules: ['web', 'log', 'assert', 'date', 'db', 'email', 'eyes', 'http']
Performs HTTP DELETE
Parameters:
Name | Type | Description |
|
| URL. |
|
|
|
http.delete('https://jsonplaceholder.typicode.com/users/1')
Performs HTTP GET
Parameters:
Name | Type | Description |
|
| URL. |
|
|
|
Returns:
Object
- Either a parsed out JSON if Content-Type is application/json or a string.
var users = http.get('https://jsonplaceholder.typicode.com/users',{ 'Content-Type': 'application/json' })log.info(users[0])
Returns response headers
Parameters:
Name | Type | Description |
|
| URL. |
Returns:
Object
- Response headers.
var url = 'https://jsonplaceholder.typicode.com'var headers = http.getResponseHeaders(url)​log.info(headers)
Performs HTTP POST
Parameters:
Name | Type | Description |
|
| URL. |
|
| Data. |
|
|
|
Returns:
Object
- Either a parsed out JSON if Content-Type is application/json or a string.
var url = 'https://jsonplaceholder.typicode.com'var post = http.post(url + '/users/1',{ country: 'Switzerland' })​log.info(post)
Performs HTTP PUT
Parameters:
Name | Type | Description |
|
| URL. |
|
| Data. |
|
|
|
Returns:
Object
- Either a parsed out JSON if Content-Type is application/json or a string.
var url = 'https://jsonplaceholder.typicode.com'var put = http.put(url + '/users/1',{ username: "NewUsername" })​log.info(put)