From dfe86127cf65e3b065a4d0f42dcc7a762374c59f Mon Sep 17 00:00:00 2001 From: Miller Correa Date: Fri, 16 Oct 2020 01:39:26 -0500 Subject: [PATCH] The Authorization parameter is received in ImportJSONViaPost and is sent through the headers. --- ImportJSON.gs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ImportJSON.gs b/ImportJSON.gs index 731806e..8a28b47 100644 --- a/ImportJSON.gs +++ b/ImportJSON.gs @@ -108,11 +108,12 @@ function ImportJSON(url, query, parseOptions) { * @param {fetchOptions} a comma-separated list of options used to retrieve the JSON feed from the URL * @param {query} a comma-separated list of paths to import. Any path starting with one of these paths gets imported. * @param {parseOptions} a comma-separated list of options that alter processing of the data + * @authorization {authorization} authorization value that will be sent in the headers usually an API KEY * @customfunction * * @return a two-dimensional array containing the data, with the first row containing headers **/ -function ImportJSONViaPost(url, payload, fetchOptions, query, parseOptions) { +function ImportJSONViaPost(url, payload, fetchOptions, query, parseOptions, authorization) { var postOptions = parseToObject_(fetchOptions); if (postOptions["method"] == null) { @@ -126,6 +127,12 @@ function ImportJSONViaPost(url, payload, fetchOptions, query, parseOptions) { if (postOptions["contentType"] == null) { postOptions["contentType"] = "application/x-www-form-urlencoded"; } + + if (authorization != null) { + postOptions["headers"] = { + Authorization : authorization + } + } convertToBool_(postOptions, "validateHttpsCertificates"); convertToBool_(postOptions, "useIntranet");