ai.https
リクエスト
方法
| 説明
|
|---|---|
request(url, method, body, headers, ) AllowAutoRedirect) | HTTPS リクエストを作成します。レスポンスを返します。
2018.3 時点で、request(method) は
|
requestStream(url, method, body, headers
2018.3 で使用可能 | HTTPS ストリーム リクエストを作成します。レスポンスを返します。
|
authenticationRequest(url, method, body, headers) | OAuth 対応 CCDS 用に生成された認証ヘッダーを持つ https リクエストを作成します。レスポンスを返します。
基になる OAuth 設定アイテムの詳細とデータ ソースの認証情報を使用して、https リクエストの認証ヘッダーを生成します。 2018.3 時点で、authorizedRequest(method) は
|
requestAuthorizedStream(url, method, body, headers)
2018.3 で使用可能 | OAuth 対応の CCDS 用に生成された認証ヘッダーを持つ HTTPS ストリーム リクエストを作成します。レスポンスを返します。
基になる OAuth 設定アイテムの詳細とデータ ソースの認証情報を使用して、https ストリーム リクエストの認証ヘッダーを生成します。 Request AuthorizedStream(meth) のサポート
|
回答
方法
| 説明
|
|---|---|
getHttpCode() | 応答の HTTP コードを返します。HTTP 応答コードの完全なリストについては、 ここをクリックしてください。 |
getHeaders() | 応答ヘッダーを返します。 |
getBody() | 回答内容を返します。 |
例
- 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); }