I'm trying to pull from the Amplitude Dashboard Rest API (documentation) in Google Apps Script, but am hitting a weird bug.
Here is the API call I want to make:
curl -u API_Key:Secret_Key 'https://amplitude.com/api/2/funnels?e={"event_type":"Any%20Active%20Event"}&e={"event_type":"Purchase%20Confirmation%20Page%20-%20Page%20View%20-%20W"\}&start=20180205&end=20180211&n=active&mode=unordered&cs=60'
And here is how my code is set up:
var headers = {
"Authorization" : "Basic " + Utilities.base64Encode("[I put my API key here]" + ':' + "[I put my secret key here]")
};
var params = {
"method":"GET",
"headers":headers
};
var url ="https://amplitude.com/api/2/funnels?e=\{"event_type":"_active"\}&e=\{"event_type":"Purchase%20Confirmation%20Page%20-%20Page%20View%20-%20W"\}&start=20180214&end=20180215&n=active&mode=ordered&cs=86400"
function callAmp() {
var response = UrlFetchApp.fetch(url, params);
Logger.log(response.getContentText());
}
I'm getting the error:
Invalid argument: https://amplitude.com/api/2/funnels?e={"event_type":"_active"}&e={"event_type":"Purchase%20Confirmation%20Page%20-%20Page%20View%20-%20W"}&start=20180214&end=20180215&n=active&mode=ordered&cs=86400
Can someone help me understand what I'm doing wrong here?