Passa al contenuto principale
Adaptive Planning
Ultimo aggiornamento: 2023-06-23
ai.https

ai.https

Richiesta

Metodo
Descrizione
request(url, method, body, headers, ) allowAutoRedirect)
Effettua una richiesta HTTPS. Restituisce una risposta.
A partire dalla versione 2018.3, request(method) è supportato
  • GET: recupera i dati.
  • POST: inoltra i dati alla risorsa specificata.
  • PUT: crea/sostituisce la risorsa specificata.
  • PATCH: applica modifiche parziali alla risorsa.
requestStream(url, method, body, headers
disponibile con 2018.3
Effettua una richiesta di flusso HTTPS. Restituisce una risposta.
  • GET: recupera i dati.
  • POST: inoltra i dati alla risorsa specificata.
  • PUT: crea/sostituisce la risorsa specificata.
  • PATCH: applica modifiche parziali alla risorsa.
authorizedRequest(url, method, body, headers)
Effettua una richiesta https con l'intestazione di autorizzazione generata per un CCDS abilitato OAuth. Restituisce una risposta.
Utilizza i dettagli dell'elemento di configurazione OAuth sottostante insieme alle informazioni di autorizzazione dell'origine dati per generare l'intestazione di autorizzazione per la richiesta https.
A partire dalla versione 2018.3, AuthorizedRequest(method) supporta
  • GET: recupera i dati.
  • POST: inoltra i dati alla risorsa specificata.
  • PUT: crea/sostituisce la risorsa specificata.
  • PATCH: applica modifiche parziali alla risorsa.
requestAuthorizedStream(url, method, body, headers)
disponibile con 2018.3
Effettua una richiesta di flusso HTTPS con l'intestazione di autorizzazione generata per un CCDS abilitato OAuth. Restituisce una risposta.
Utilizza i dettagli dell'elemento di configurazione OAuth sottostante insieme alle informazioni di autorizzazione dell'origine dati per generare l'intestazione di autorizzazione per la richiesta di flusso https.
RequestAuthorizedStream(method) supporta
  • GET: recupera i dati.
  • POST: inoltra i dati alla risorsa specificata.
  • PUT: crea/sostituisce la risorsa specificata.
  • PATCH: applica modifiche parziali alla risorsa.

Risposta

Metodo
Descrizione
getHttpCode()
Restituisce il codice HTTP della risposta. Per un elenco completo dei codici di risposta HTTP, fare clic qui.
getHeaders()
Restituisce le intestazioni delle risposte.
getBody()
Restituisce il contenuto della risposta.

Esempi

ai.https.request
function testConnection(context) { //This example connects to Postman Echo using GET var URL = 'https://postman-echo.com/get?foo1=bar1&foo2=bar2'; var method = 'GET'; var body = ''; var headers = null; //ai.https.request var response = ai.https.request(URL, method, body, headers); var responseCode = response.getHttpCode(); if (responseCode == 200) { ai.log.logInfo('Test Connection Succeeded','Response code was 200'); return true; } else{ ai.log.logInfo('Test Connection Failed','Response code was not 200'); return false; } }
ai.https.requestStream
function testConnection(context) { //This example connects to Postman Echo using GET var URL = 'https://postman-echo.com/get?foo1=bar1&foo2=bar2'; var method = 'GET'; var body = ''; var headers = null; var response = ai.https.requestStream(URL, method, body, headers); return true; }
ai.https.authorizedRequest
function testConnection(context) { //This example connects to Postman Echo using GET var URL = 'https://postman-echo.com/basic-auth'; var method = 'GET'; var username='postman'; var pwd='password'; var body = '<username>'+username+'</username><password>'+pwd+'</password>'; var headers = {'Authorization': 'Basic cG9zdG1hbjpwYXNzd29yZA=='}; var response = ai.https.authorizedRequest(URL, method, body, headers); var responseCode = response.getHttpCode(); ai.log.logInfo(responseCode); if (responseCode == 200) { ai.log.logInfo('Test Connection Succeeded','Response code was 200'); var responseBody = response.getBody(); ai.log.logInfo(responseBody); //{"authenticated":true} return true; } else{ ai.log.logInfo('Test Connection Failed','Response code was not 200'); return false; } }
ai.requestAuthorizedStream
function testConnection(context) { //This example connects to Postman Echo using GET var URL = 'https://postman-echo.com/basic-auth'; var method = 'GET'; var username='postman'; var pwd='password'; var body = '<username>'+username+'</username><password>'+pwd+'</password>'; var headers = {'Authorization': 'Basic cG9zdG1hbjpwYXNzd29yZA=='}; var response = ai.https.requestAuthorizedStream(URL, method, body, headers); }