Skip to content

Instantly share code, notes, and snippets.

@jurby
Created October 18, 2013 21:51
Show Gist options
  • Save jurby/7048798 to your computer and use it in GitHub Desktop.
Save jurby/7048798 to your computer and use it in GitHub Desktop.
//Send Google Apps Script data to a Couch DB database
function syncWithDB(data){
var username = ScriptProperties.getProperty('user');
var password = ScriptProperties.getProperty('pass');
var url = 'https://[username].cloudant.com/[dbname]/_bulk_docs';
var params = {
"method" : "post",
"contentType":"application/json",
"validateHttpsCertificates" :false,
"payload" : JSON.stringify(data),
"headers":{
"Authorization": "Basic " + Utilities.base64Encode(username + ":" + password)
}
}
return UrlFetchApp.fetch(url, params);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment