NSOA.https.get(request)
Use this function to send an HTTPS GET request to retrieve data from a server. The data is identified by a unique URL and parameters can be passed to the server using query string parameters. What data is returned depends on the implementation of the server. The function will return an error if the URL requested does not use the HTTPS protocol. The function will follow redirects up to a maximum of 7. The response must not exceed 1MB in size.
If the client doesn’t start receiving a response from the server within 45 seconds of the request being fully sent, a connection timeout occurs. If the request times out, a response object is returned with a standard HTTP Status Code (500) and a "Client-Warning" header set.
Parameters
-
request {object} [required] — The request object is used to set the GET request parameters
Property |
Type |
Required / Optional |
Description |
---|---|---|---|
url |
string |
required |
The HTTPS URL being requested. |
headers |
object |
optional |
The HTTPS headers. |
Returns
-
response {object} [read-only] — The NSOA.https.get function returns the response object.
Property |
Type |
Description |
---|---|---|
body |
string|object |
The GET data. |
code |
string |
The HTTP response status code. |
headers |
object |
The response headers. |
Units Limit
-
10 units
For more information, see Scripting Governance.
Since
-
April 13, 2019
Example
-
This example sends an HTTPS GET request, converts the response to a JSON string, displays it in a confirmation message and stores it as a log entry.
function main(type) { var response = NSOA.https.get({ url: 'https://postman-echo.com/get?foo1=bar1&foo2=bar2' }); NSOA.meta.alert(JSON.stringify(response)); NSOA.form.confirmation(JSON.stringify(response)); }
-
This example sends an HTTPS GET request to an endpoint simulating a basic-auth protected endpoint. It converts the response to a JSON string, stores it as a log entry and displays a confirmation message if the authentication is succesful.
function main(type) { var response = NSOA.https.get({ url: 'https://postman-echo.com/basic-auth', headers: {'Authorization':'Basic cG9zdG1hbjpwYXNzd29yZA=='} }); NSOA.meta.alert(JSON.stringify(response)); if (response.body.authenticated) { NSOA.form.confirmation('Authentification successful'); } }
See Code Samples for more examples.