Proxy Get Config

Proxy Get Config - kintone.plugin.app.getProxyConfig()

Retrieves the headers and data that will be added to the request when running an external Web API with the following API.
Plug-in Proxy Request

This information will first need to be saved using the following API.
Proxy Set Config

Function

kintone.plugin.app.getProxyConfig(url, method)

Parameters

PARAMETER TYPE REQUIRED DESCRIPTION
url String Yes The URL of the API to be run.
method String Yes The HTTP method. Specify one of the following: GET / POST / PUT / DELETE.

Returns

A JSON containing headers and data for the request required to run the external Web API.

PARAMETER TYPE DESCRIPTION
headers Object Request header specified as headers in Proxy Set Config API.
data Object Request body specified as data in Proxy Set Config API.
  • null is returned for pages where it cannot be used.
  • null is returned, if there is no configuration settings set by Proxy Set Config API that matches.

Available Pages

This method can be used in the following pages:

  • Plug-in Settings

Sample

Sample of using this API to retrieve saved values:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
const headers = {
  Authorization: 'Bearer TEST_TOKEN',
};
const data = {
  key1: '1',
  key2: true
};
kintone.plugin.app.setProxyConfig('https://api.example.com', 'POST', headers, data);
const config = kintone.plugin.app.getProxyConfig('https://api.example.com', 'POST');
console.log(config);

Notes

When using this API to retrieve the value specified for headers in Proxy Set Config API, the value will always be a string.

For example, when integer or boolean values are assigned to the headers:

1
2
3
4
5
const headers = {
  key1: 1,
  key2: true,
};
kintone.plugin.app.setProxyConfig('https://api.example.com', 'POST', headers, {}, () => console.log('Saved!'));

In this case, when the following API is executed, values of integer or boolean types are returned as string types:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
const config = kintone.plugin.app.getProxyConfig('https://api.example.com', 'POST');
console.log(config);
// response

/**
 * 1 and true are returned as string types
 * {
 *    headers: {
 *      "key1": "1", // string
 *      "key2": "true",  // string
 *    },
 *    data: {},
 *  }
 **/