Created
June 18, 2016 13:02
-
-
Save tariqhamid/4869aa8279f5cbc6de7f404a9da25f0e to your computer and use it in GitHub Desktop.
Send Google Apps Script data to a Cloudant CouchDB database.
This file contains 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