Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Resolved /bradjasper/ImportJSON#112 #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ImportJSON.gs
Original file line number Diff line number Diff line change
@@ -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");