Rich-text Reply

Connect Optimizely Rest Api to a google sheet

Nicolas_Hemidy 06-21-16

Connect Optimizely Rest Api to a google sheet

Hi there,


I'm trying to connect the Optimizely Rest API to a google sheet in order to preview my experiment results directly into a google sheet. I found this page explaining how to connect to an API and created the following code into a google script:


function ConnectApi() {
var url = '-H"Token:[mytoken]"\""';
var response = UrlFetchApp.fetch(url);
var json = response.getContentText();
var data = JSON.parse(json);


I get an error every time and It seems that I don't use it in the proper way. 

Does anyone have already done that and could help me?

Thanks a lot in advance,


AllisonR 06-22-16

Re: Connect Optimizely Rest Api to a google sheet

[ Edited ]

Hi Nicolas,


It looks like there is an issue with the format of the HTTPS request you are trying to send. You'll need to send the token in the header of the request. This is one way to do so: 


function ConnectApi() {
	var token = [yourToken];
	var url = "";
	var headers = {
		"Token": token
	var options = {
		"headers": headers
	var response = UrlFetchApp.fetch(url, options);
	var json = response.getContentText();
	return json;

You'll need to fill in your API token as a string in the above sample. You can grab your API token here: 


Does this work for you? 

Sr. Technical Support Engineer
Optimizely | EMEA