Created
October 18, 2013 21:51
-
-
Save jurby/7048798 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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