Proxy Request

Proxy Request - kintone.proxy()

This API makes requests to external APIs. CORS errors (External link) can be avoided by using this API.

Function

kintone.proxy(url, method, headers, data, successCallback, failureCallback)

Parameters

PARAMETER VALUE REQUIRED DESCRIPTION
url String Yes The request URL.
method String Yes The HTTP method. Specify one of the following: GET / POST / PUT / DELETE.
headers Object Yes Specify the request header as an object. To ignore this parameter, input {}.
Sample: { 'Content-Type': 'application/json' }
data Object or String Yes The data that will be sent in the request.To ignore this parameter, input {}.
Applied only for POST/PUT requests. Ignored for GET/DELETE requests.
For GET/DELETE requests, set the parameter on the QueryString of the URL instead.
successCallback Function Optional The callback function that will run once the request to the other end of the proxy has finished. It will receive the response body (string), the status code (number) and the response header (object) as parameters from the external API.

If ignored, a kintone.Promise object will be returned that can be fulfilled with an array containing a Response body (string), Status code (number) and Response header (object).
failureCallback Function Optional The callback function that will run when the API request to the other end of the proxy fails. It will receive the response body (string) as the parameter from the external API.
If the callback is ignored, a kintone.Promise object will be returned that can be fulfilled with the Response body (string) from the proxy API.

Response

A kintone.Promise object will be returned if the successCallback or failureCallback parameters are ignored. Otherwise, there will be no response.

Sample Request

1
2
3
4
5
kintone.proxy('https://*****.***.net', 'GET', {}, {}, function(body, status, headers) {
  console.log(status, JSON.parse(body), headers);
}, function(error) {
  console.log(error); // Display the response body (string) from the proxy API
});

Sample Request using Promises

1
2
3
4
5
6
7
8
9
kintone.proxy('https://*****.***.net', 'GET', {}, {}).then(function(args) {
  /*  args[0] -> body(string)
   *  args[1] -> status(number)
   *  args[2] -> headers(object)
   */
  console.log(args[1], JSON.parse(args[0]), args[2]);
}, function(error) {
  console.log(error); // Display the response body (string) from the proxy API
});

Notes

  • Any kind of Content-type can be used.
  • Specifying a non-existent url will return an error status code of 503 (DNS Cache Missing).
  • If IP Address restrictions are enabled on the origin subdomain, the kintone.com IP Address must be allowed access, if using kintone.proxy() on an App within a different subdomain. A list of IP Addresses used by Kintone can be found on the Domains and IP Addresses Used by Kintone (External link) Help site. Please note that this will allow any Kintone domain to bypass IP address restrictions, and therefore is not recommended from a security standpoint.
  • When using Kintone REST API on your own Kintone domain, use the Kintone REST API Request instead of the kintone.proxy() API.

Limitations

  • This API can be used on both Desktops and Smartphones.
  • This API cannot be initiated from apps attached to bodies of Spaces/Threads/Announcements.
  • The site on the other end of the proxy will not automatically issue cookies.
  • The maximum lines of the response header from the other end of the proxy is 100 lines, and the maximum size for each line is 8192 bytes.
  • This API can only handle a response body of characters. Images, or other binary data are not supported.
  • The maximum size of the response body from the other end of the proxy is 10MB.
  • Servers using self-signed SSL certificates are not supported.
  • The Content-Length header and Transfer-Encoding headers are automatically added if the HTTP Method is set to POST or PUT.
  • Explicitly setting headers will cause an error.