---
sourceDocument: Xanadu API リファレンス
sourceDocumentLink: https://www.servicenow.com/docs/r/ja-JP/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - ja-JP

ft:publication_title :

    - Xanadu API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# GlideHTTPResponse - グローバル

# GlideHTTPResponse - グローバル {#ariaid-title1}

* リリースバージョン: Xanadu
* 
* 更新日 2024年08月01日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：25分

GlideHTTPResponse API は、Glide HTTP 応答で一般的な機能を実行するためのユーティリティメソッドを提供します。

## GlideHTTPResponse - getAllHeaders() {#ariaid-title2}

すべてのヘッダーのリストを返します。
{#GlideHTTPResponse-getAllHeaders__table_azk_y32_dfb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 1. パラメーター]

{#GlideHTTPResponse-getAllHeaders__table_azk_y32_dfb} {#GlideHTTPResponse-getAllHeaders__table_bzk_y32_dfb__entry__2}

| タイプ | 説明 |
|-|-|
| アレイ | エンドポイント呼び出しに関連付けられているすべてのヘッダーのリスト。 |
[表 : 2. 返される内容]

{#GlideHTTPResponse-getAllHeaders__table_bzk_y32_dfb}  
この例は、del() メソッドを使用してインシデントテーブルから指定されたインシデントを削除する方法を示しています。

    var instance = 'dev12345';
    var username = 'admin';
    var password = 'yourpassword';

    // Instantiate request with ServiceNow API incidents table endpoint
    var request = new GlideHTTPRequest('https://'+instance+'.service-now.com/api/now/table/incident');

    // Add authentication data
    request.setBasicAuth(username, password);

    // Add the Accept header to get JSON response
    request.addHeader('Accept', 'application/json');

    // Execute the GET request
    var response = request.get();

    // Print all headers associated with the endpoint call
    gs.print(response.getAllHeaders());

出力

    [
      X-Is-Logged-In: true, 
      X-Transaction-ID: 21a9223f1b13, 
      X-Total-Count: 69,
      X-Content-Type-Options: nosniff,
      Pragma: no-store,no-cache,
      Cache-Control: no-cache,no-store,must-revalidate,
      max-age=-1,
      Expires: 0,
      Content-Type: application/json;charset=UTF-8,
      Transfer-Encoding: chunked,
      Date: Tue, 26 Oct 2021 16:54:24 GMT,
      Server: ServiceNow,
      Set-Cookie: JSESSIONID=36B9B3E86C31E244A50AF38106376F9B; Path=/; HttpOnly; SameSite=None; Secure,
      Set-Cookie: glide_user=; Max-Age=0; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly; SameSite=None; Secure,
      Set-Cookie: glide_user_session=; Max-Age=0; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly; SameSite=None; Secure,
      Set-Cookie: glide_user_route=glide.455981d2bb48a9658f44c18e5f56313d; Max-Age=2147483647; Expires=Sun, 13-Nov-2089 20:08:31 GMT; Path=/; HttpOnly; SameSite=None; Secure,
      Set-Cookie: glide_session_store=E9A9223F1B1370107CF30D03CD4BCB8D; Max-Age=1800; Expires=Tue, 26-Oct-2021 17:24:24 GMT; Path=/; HttpOnly; SameSite=None; Secure,
      Set-Cookie: BIGipServerpool_jsmith=428037898.31808.0000; path=/; Httponly; Secure; SameSite=None; Secure, Strict-Transport-Security: max-age=63072000; includeSubDomains
    ]

## GlideHTTPResponse - getBody() {#ariaid-title3}

HTTP 応答の本文を含む文字列を返します。
注:  
ストリームが既にアクセスされている場合、再度アクセスすることはできません。この場合、メソッドは null を返します。
{#GlideHTTPResponse-getBody__table_mwd_gt2_dfb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 3. パラメーター]

{#GlideHTTPResponse-getBody__table_mwd_gt2_dfb} {#GlideHTTPResponse-getBody__table_nwd_gt2_dfb__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | HTTP 応答本文。 |
[表 : 4. 返される内容]

{#GlideHTTPResponse-getBody__table_nwd_gt2_dfb}  
この例は、getBody() メソッドを使用して、エンドポイント呼び出しで返される結果の内容を表示する方法を示しています。

    var instance = 'dev12345';
    var username = 'admin';
    var password = 'yourpassword';

    // Instantiate request with ServiceNow API incidents table endpoint
    var request = new GlideHTTPRequest('https://'+instance+'.service-now.com/api/now/table/incident');

    // Add authentication data
    request.setBasicAuth(username, password);

    // Add the Accept header to get JSON response
    request.addHeader('Accept', 'application/json');
    request.addHeader('Content-Type','application/json');
     
    var response = request.post('{"short_description":"Test me"}');
     
    gs.print(response.getStatusCode());
    gs.print(response.getBody());

出力

    201
    {
      "result":{
        "parent":"",
        "made_sla":"true",
        "caused_by":"",
        "watch_list":"",
        "upon_reject":"cancel",
        "sys_updated_on":"2021-10-26 14:59:22",
        "child_incidents":"0",
        "hold_reason":"",
        "task_effective_number":"INC0010003",
        "approval_history":"",
        "skills":"",
        "number":"INC0010003",
        "resolved_by":"",
        "sys_updated_by":"admin",
        "opened_by":{
          "link":"https://instanceName.servicenow.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441",
          "value":"6816f79cc0a8016401c5a33be04be441"
        },
        "user_input":"",
        "sys_created_on":"2021-10-26 14:59:22",
        "sys_domain":{
          "link":"https://instanceName.servicenow.com/api/now/table/sys_user_group/global",
          "value":"global"
        },
        "state":"1",
        "route_reason":"",
        "sys_created_by":"admin",
        "knowledge":"false",
        "order":"",
        "calendar_stc":"",
        "closed_at":"",
        "cmdb_ci":"",
        "delivery_plan":"",
        "contract":"",
        "impact":"3",
        "active":"true",
        "work_notes_list":"",
        "business_service":"",
        "priority":"5",
        "sys_domain_path":"/",
        "rfc":"",
        "time_worked":"",
        "expected_start":"",
        "opened_at":"2021-10-26 14:59:22",
        "business_duration":"",
        "group_list":"",
        "work_end":"",
        "caller_id":"",
        "reopened_time":"",
        "resolved_at":"",
        "approval_set":"",
        "subcategory":"",
        "work_notes":"",
        "universal_request":"",
        "short_description":"Test me",
        "close_code":"",
        "correlation_display":"",
        "delivery_task":"",
        "work_start":"",
        "assignment_group":"",
        "additional_assignee_list":"",
        "business_stc":"",
        "description":"",
        "calendar_duration":"",
        "close_notes":"",
        "notify":"1",
        "service_offering":"",
        "sys_class_name":"incident",
        "closed_by":"",
        "follow_up":"",
        "parent_incident":"",
        "sys_id":"a85f82ffdb5f30103dd9c39d13961916",
        "contact_type":"",
        "reopened_by":"",
        "incident_state":"1",
        "urgency":"3",
        "problem_id":"",
        "company":"",
        "reassignment_count":"0",
        "activity_due":"",
        "assigned_to":"",
        "severity":"3",
        "comments":"",
        "approval":"not requested",
        "sla_due":"",
        "comments_and_work_notes":"",
        "due_date":"",
        "sys_mod_count":"0",
        "reopen_count":"0",
        "sys_tags":"",
        "escalation":"0",
        "upon_approval":"proceed",
        "correlation_id":"",
        "location":"",
        "category":"inquiry"
      }
    }

## GlideHTTPResponse - getCookies() {#ariaid-title4}

エンドポイント呼び出しに関連付けられた cookie のリストを返します。
{#GlideHTTPResponse-getCookies__table_qmw_jj2_dfb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 5. パラメーター]

{#GlideHTTPResponse-getCookies__table_qmw_jj2_dfb} {#GlideHTTPResponse-getCookies__table_rmw_jj2_dfb__entry__2}

| タイプ | 説明 |
|-|-|
| アレイ | 各 cookie の名前と値を文字列として含むリスト。 |
[表 : 6. 返される内容]

{#GlideHTTPResponse-getCookies__table_rmw_jj2_dfb}  
この例では、getCookies() メソッドを使用してエンドポイント応答に関連付けられた cookie を表示する方法を示します。

    var instance = 'dev12345';
    var username = 'admin';
    var password = 'yourpassword';

    // Instantiate request with ServiceNow API incidents table endpoint
    var request = new GlideHTTPRequest('https://'+instance+'.service-now.com/api/now/table/incident');

    // Add authentication data
    request.setBasicAuth(username, password);

    // Add the Accept header to get JSON response
    request.addHeader('Accept', 'application/json');

    // Execute the GET request
    var response = request.get();

    // Print the results: status code and number of records returned
    gs.print(response.getStatusCode());
    gs.print(response.getCookies());

出力

    200
    [
      JSESSIONID=B8E5C1C0E43FEA35EC0FCB323A9DF8D1; 
      Path=/; HttpOnly; SameSite=None; Secure, glide_user=; Max-Age=0; Expires=Thu, 01-Jan-1970 00:00:10 GMT;
      Path=/; HttpOnly; SameSite=None; Secure, glide_user_session=; Max-Age=0; Expires=Thu, 01-Jan-1970 00:00:10 GMT;
      Path=/; HttpOnly; SameSite=None; Secure, glide_user_route=glide.f1aa2015b3fa5fa8dfe567386cde8fd5; Max-Age=2147483647; Expires=Sun, 13-Nov-2089 21:02:31 GMT;
      Path=/; HttpOnly; SameSite=None; Secure, glide_session_store=7406BAB7DBDF30103DD9C39D13961966; Max-Age=1800; Expires=Tue, 26-Oct-2021 18:18:24 GMT;
      Path=/; HttpOnly; SameSite=None; Secure, BIGipServerpool_jsmith=2643023626.45630.0000; path=/; Httponly; Secure; SameSite=None; Secure
    ]

## GlideHTTPResponse - getErrorCode() {#ariaid-title5}

エンドポイントによって返された現在のエラーコードを返します。
{#GlideHTTPResponse-getErrorCode__table_q4d_t52_dfb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 7. パラメーター]

{#GlideHTTPResponse-getErrorCode__table_q4d_t52_dfb} {#GlideHTTPResponse-getErrorCode__table_r4d_t52_dfb__entry__2}

| タイプ | 説明 |
|-|-|
| 整数 | エラーコード。エラーがない場合は 0 が返されます。 |
[表 : 8. 返される内容]

{#GlideHTTPResponse-getErrorCode__table_r4d_t52_dfb}  
この例は、getErrorCode() メソッドを使用して、関連する REST 呼び出しのインスタンスによってスローされた前回のエラーメッセージのエラーコードを表示する方法を示しています。

    var instance = 'dev12345'; // Instance name
    var username = 'admin';
    var password = 'yourpassword';
    var sysId = '0123456789abcdef0123456789abcdef';  // Sys_id of the incident to get

    // Instantiate request with the ServiceNow API incident table endpoint for deletion of an incident
    var endpoint = 'https://' + instance + '.service-now.com/api/now/table/incident/' + sysId;
    var request = new GlideHTTPRequest(endpoint);

    // Add authentication data
    request.setBasicAuth(username, password);

    // Delete the incident
    response = request.get();

    // Print the results: status code and response body
    gs.print(response.getStatusCode());

    // Get the last error message
    gs.print(response.getErrorCode());

出力

    404
    1

## GlideHTTPResponse - getErrorMessage() {#ariaid-title6}

前回発生したエラーを返します。
{#GlideHTTPResponse-getErrorMessage__table_llx_pxy_cfb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 9. パラメーター]

{#GlideHTTPResponse-getErrorMessage__table_llx_pxy_cfb} {#GlideHTTPResponse-getErrorMessage__table_mlx_pxy_cfb__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | 前回発生したエラーを説明するテキスト文字列。 |
[表 : 10. 返される内容]

{#GlideHTTPResponse-getErrorMessage__table_mlx_pxy_cfb}  
この例は、getErrorMessage() メソッドを使用して、関連する REST 呼び出しのインスタンスによってスローされた前回のエラーメッセージを表示する方法を示しています。

    var instance = 'dev12345'; // Instance name
    var username = 'admin';
    var password = 'yourpassword';
    var sysId = '0123456789abcdef0123456789abcdef';  // Sys_id of the incident to get

    // Instantiate request with the ServiceNow API incident table endpoint for deletion of an incident
    var endpoint = 'https://' + instance + '.service-now.com/api/now/table/incident/' + sysId;
    var request = new GlideHTTPRequest(endpoint);

    // Add authentication data
    request.setBasicAuth(username, password);

    // Try to get the non-existent incident
    response = request.get();

    // Print the results: status code and response body
    gs.print(response.getStatusCode());

    // Get the last error message
    gs.print(response.getErrorMessage());

出力

    404
    Method failed: (/api/now/table/incident/0123456789abcdef0123456789abcdef) with code: 404

## GlideHTTPResponse - getHeader(文字列 name) {#ariaid-title7}

渡されたパラメーターで指定されたヘッダーを返します。
{#GlideHTTPResponse-getHeader__table_rsl_c22_dfb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| name | 文字列 | Content-Type など、返される応答ヘッダーの名前。 |
[表 : 11. パラメーター]

{#GlideHTTPResponse-getHeader__table_rsl_c22_dfb} {#GlideHTTPResponse-getHeader__table_ssl_c22_dfb__entry__2}

| タイプ | 説明 |
|-|-|
| 文字列 | 現在の応答の指定されたヘッダーの値。 |
[表 : 12. 返される内容]

{#GlideHTTPResponse-getHeader__table_ssl_c22_dfb}  
この例は、Content-Type ヘッダーの内容を表示する方法を示しています。

    var instance = 'dev12345'; // Instance name
    var username = 'admin';
    var password = 'yourpassword';
    var sysId = '0123456789abcdef0123456789abcdef';  // Sys_id of the incident to get

    // Instantiate request with the ServiceNow API incident table endpoint for deletion of an incident
    var endpoint = 'https://' + instance + '.service-now.com/api/now/table/incident/' + sysId;
    var request = new GlideHTTPRequest(endpoint);

    // Add authentication data
    request.setBasicAuth(username, password);

    // Execute the GET request
    var response = request.get();

    // Print the results
    gs.print(response.getStatusCode());
    gs.print(response.getHeader("Content-Type"));

出力

    200
    application/json

## GlideHTTPResponse - getHeaders() {#ariaid-title8}

エンドポイント応答に関連付けられたすべてのヘッダーを返します。
{#GlideHTTPResponse-getHeaders__table_jyb_l32_dfb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 13. パラメーター]

{#GlideHTTPResponse-getHeaders__table_jyb_l32_dfb} {#GlideHTTPResponse-getHeaders__table_kyb_l32_dfb__entry__2}

| タイプ | 説明 |
|-|-|
| オブジェクト | 関連するすべてのヘッダーを含むオブジェクト。 |
[表 : 14. 返される内容]

{#GlideHTTPResponse-getHeaders__table_kyb_l32_dfb}  
この例は、getHeaders() メソッドを使用して、エンドポイント呼び出しに関連付けられたすべてのヘッダーを表示する方法を示しています。

    var instance = 'dev12345'; // Instance name
    var username = 'admin';
    var password = 'yourpassword';
    var sysId = '0123456789abcdef0123456789abcdef';  // Sys_id of the incident to get

    // Instantiate request with the ServiceNow API incident table endpoint for deletion of an incident
    var endpoint = 'https://' + instance + '.service-now.com/api/now/table/incident/' + sysId;
    var request = new GlideHTTPRequest(endpoint);

    // Add authentication data
    request.setBasicAuth(username, password);

    // Execute the GET request
    var response = request.get();

    // Print the results
    gs.print(response.getStatusCode());
    gs.print(response.getHeaders());

出力

    200
    {
      Transfer-Encoding=chunked, 
      Strict-Transport-Security=max-age=63072000; includeSubDomains,
      Cache-Control=no-cache, no-store, must-revalidate,
      max-age=-1,
      Server=ServiceNow,
      X-Content-Type-Options=nosniff,
      X-Transaction-ID=399f8f73db13,
      X-Is-Logged-In=true,
      Set-Cookie=BIGipServerpool_jsmith=2643023626.45630.0000; path=/; Httponly; Secure; SameSite=None; Secure,
      Pragma=no-store,no-cache, Expires=0, Date=Tue, 26 Oct 2021 19:40:10 GMT, 
      Content-Type=application/json;charset=UTF-8
    }

## GlideHTTPResponse - getHttpMethod() {#ariaid-title9}

指定されたエンドポイント呼び出しに関連付けられた HTTP メソッドを返します。
{#GlideHTTPResponse-getHttpMethod__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 15. パラメーター]

{#GlideHTTPResponse-getHttpMethod__entry__8}

| タイプ | 説明 |
|-|-|
| 文字列 | エンドポイント呼び出しに関連付けられた HTTP メソッド (`org.apache.commons.httpclient.methods.GetMethod@f83e63` など)。 形式：org.apache.commons.httpclient.methods.\<メソッド\> |
[表 : 16. 返される内容]

この例は、getMethod() メソッドを使用して関連するエンドポイントを呼び出すときに使用される HTTP メソッドを表示する方法を示しています。

    var instance = 'dev12345'; // Instance name
    var username = 'admin';
    var password = 'yourpassword';
    var sysId = '0123456789abcdef0123456789abcdef';  // Sys_id of the incident to get

    // Instantiate request with the ServiceNow API incident table endpoint for deletion of an incident
    var endpoint = 'https://' + instance + '.service-now.com/api/now/table/incident/' + sysId;
    var request = new GlideHTTPRequest(endpoint);

    // Add authentication data
    request.setBasicAuth(username, password);

    // Execute the GET request
    var response = request.get();

    // Print the results
    gs.print(response.getStatusCode());
    gs.print(response.getHttpMethod());

出力

    200
    org.apache.commons.httpclient.methods.GetMethod@f83e63

## GlideHTTPResponse - getStatusCode() {#ariaid-title10}

エンドポイント呼び出しの前回のステータスコードを返します。
{#GlideHTTPResponse-getStatusCode__table_cnd_fd2_dfb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 17. パラメーター]

{#GlideHTTPResponse-getStatusCode__table_cnd_fd2_dfb} {#GlideHTTPResponse-getStatusCode__table_dnd_fd2_dfb__entry__2}

| タイプ | 説明 |
|-|-|
| int | HTTP 応答ステータスコード。 |
[表 : 18. 返される内容]

{#GlideHTTPResponse-getStatusCode__table_dnd_fd2_dfb}  
この例は、REST 呼び出しが getStatusCode() メソッドを使用して実行された後に、そのステータスコードを取得する方法を示しています。

    var instance = 'dev12345';
    var username = 'admin';
    var password = 'yourpassword';

    // Instantiate request with ServiceNow API incidents table endpoint
    var request = new GlideHTTPRequest('https://'+instance+'.service-now.com/api/now/table/incident');

    // Add authentication data
    request.setBasicAuth(username, password);

    // Add the 'sysparm_limit' parameter to limit the number of records returned
    request.addParameter('sysparm_limit', 1);

    // Execute the GET request
    var response = request.get();

    // Print the results: status code
    gs.print(response.getStatusCode());

出力:

    200

## GlideHTTPResponse - haveError() {#ariaid-title11}

エンドポイント呼び出しの処理中にエラーが発生したかどうかを示すフラグを返します。
{#GlideHTTPResponse-haveError__table_ypm_g52_dfb__entry__3}

| 名前 | タイプ | 説明 |
|-|-|-|
| なし |   |   |
[表 : 19. パラメーター]

{#GlideHTTPResponse-haveError__table_ypm_g52_dfb} {#GlideHTTPResponse-haveError__table_zpm_g52_dfb__entry__2}

| タイプ | 説明 |
|-|-|
| ブーリアン | エンドポイント呼び出しの処理中にエラーが発生したかどうかを示すフラグ。 有効な値： * true：エンドポイントの処理中にエラーが発生しました。 * false：エンドポイントの処理中にエラーは発生しませんでした。 エラーが発生した場合は true を返し、エラーがない場合は false を返します。 |
[表 : 20. 返される内容]

{#GlideHTTPResponse-haveError__table_zpm_g52_dfb}  
この例は、haveError() メソッドを使用して、インシデントの sys_id が有効である場合にエラーなしのフラグを付ける方法を示しています。

    var instance = 'dev12345';
    var username = 'admin';
    var password = 'yourpassword';

    // Valid sys_id of an incident record
    var sysId = 'a85f82ffdb5f30103dd9c39d13961916';  // Sys_id of the incident to get

    // Instantiate request with the ServiceNow API incident table endpoint for deletion of an incident
    var endpoint = 'https://' + instance + '.service-now.com/api/now/table/incident/' + sysId;
    var request = new GlideHTTPRequest(endpoint);

    // Add authentication data
    request.setBasicAuth(username, password);

    // Execute the GET request
    var response = request.get();

    // Print the results
    gs.print(response.getStatusCode());
    gs.print(response.haveError());

出力

    200
    false

この例は、haveError() メソッドを使用して、インシデントの sys_id が有効でない場合にエラーのフラグを付ける方法を示しています。

    var instance = 'dev12345';
    var username = 'admin';
    var password = 'yourpassword';

    // Invalid sys_id
    var sysId = 'a85f82ffdb5f30103dd9c39d13961832';  // Sys_id of the incident to get

    // Instantiate request with the ServiceNow API incident table endpoint for deletion of an incident
    var endpoint = 'https://' + instance + '.service-now.com/api/now/table/incident/' + sysId;
    var request = new GlideHTTPRequest(endpoint);

    // Add authentication data
    request.setBasicAuth(username, password);

    // Execute the GET request
    var response = request.get();

    // Print the results
    gs.print(response.getStatusCode());
    gs.print(response.haveError());

出力

    404
    true


