Proxy Set Config

Proxy Set Config - kintone.plugin.app.setProxyConfig()

Saves the plug-in configuration settings that can be later retrieved with the kintone.plugin.app.proxy() API.

Function

kintone.plugin.app.setProxyConfig(url, method, headers, data, successCallback)

Parameters

PARAMETER TYPE REQUIRED DESCRIPTION
url String Yes Part or all of the REST API URL.
Check Conditions for Saved Data to be Added to the Request for conditions for data to be added to the API request.
method String Yes The HTTP method. Specify one of the following: GET / POST / PUT / DELETE.
headers Object Yes The parameters that will be added to the request header of the API.
If parameter names overlap with parameters specified with kintone.plugin.app.proxy(), then the parameters specified here will take priority. For more information, refer to the following article:
Plug-in Proxy Request
Leave this as {} if parameters are not needed.
data Object Yes Specify data that will be added to the API request data, as an object with a set of key and values inside.
Example:
{
"key1": "value1",
"key2": "value2"
}
If key names overlap with keys specified with kintone.plugin.app.proxy(), then the property values specified here will take priority. For more information, refer to the following article:
Plug-in Proxy Request
Leave this as {} if keys are not needed.
Object type values cannot be specified as the property values.
successCallback Function Optional The function to be called after the settings have been successfully saved. There are no parameters. If this is undefined, null or is not specified, the page will navigate to the plug-in list page and display a message stating the settings have finished.
If a callback function is specified, the page will not navigate to the plug-in list page.

Response

None

Available Pages

This method can be used in the following pages:

  • Plug-in Settings

Sample

1
2
3
4
5
6
7
8
var headers = {
  'Content-Type': 'application/json',
  'Authorization': '777-777-abcded-ghijkl'
};
var data = {
  'key1': 'secretValue'
};
kintone.plugin.app.setProxyConfig('https://api.example.com', 'GET', headers, data);

After the above settings have been saved, let's say you used "kintone.plugin.app.proxy()" to run an API, with the URL https://api.example.com/rest/operate.json and a header of {}.
In this case, the request header that will be sent will become:

1
{ "Content-Type": "application/json", "Authorization": "777-777-abcded-ghijkl" }

Saved Format

The data saved by this API will be saved in the following format:

  • URL
  • HTTP Method (GET/POST/PUT/DELETE)
  • Saved Data
  • An object will be saved with a set of keys and values including the following:
    • Request Header
    • Request Data

If you specify a URL and HTTP method set that's already been saved to the plug-in, the new information will override it.

Conditions for Saved Data to be Added to the Request

The saved information will be added to the requests that use kintone.plugin.app.proxy(), and also meet all of the following conditions:

  • The apps are the same
  • The Plug-ins are the same
  • The HTTP method is the same
  • The URL of the API that is called forward matches

Forward matching URL examples

Example 1

For example, if the below API and URL is used to save settings to the plug-in,

1
2
kintone.plugin.app.setProxyConfig()
https://api.example.com/

and the below API and URL is called to run an external REST API,

1
2
kintone.plugin.app.proxy()
https://api.example.com/operate.json

then the URLs will forward match, and the data saved in the plug-in (saved by kintone.plugin.app.setProxyConfig()) will be added to the request.
Note that the URLs are case-sensitive.

Example 2

If you've saved several settings to the plug-in, the URL in the settings that match the most characters with the URL called by kintone.plugin.app.proxy() will be prioritized.
For example, let's say we used kintone.plugin.app.setProxyConfig() to save the following two settings to the plug-in:

1
2
3
4
5
6
7
Setting 1
URL:https://api.example.com/
Header:{"Content-Type": "application/x-www-form-urlencoded"}

Setting 2
URL:https://api.example.com/rest/
Header:{"Content-Type": "application/json"}

If we call kintone.plugin.app.proxy() to run an external REST API with the following information,

1
2
URL:https://api.example.com/rest/operate.json
Header:{}

the request header that will be sent by the API will become:

1
{ "Content-Type": "application/json" }