Google Spreadsheet + JSON + Solve360 CRM

Here a sample code to get a JSON response using Google Apps Script from Solve360 CRM

Based on change some lines of code into the Solve360 Service library for Google Apps Scripts


/**
* Request to the Solve360 API server
* data should be an Array in Short Hand notation
*/
request : function(uri, restVerb, data) {
if (this._credentials == null) {
throw new Error(‘Solve360 credentials are not set’);
}
if (typeof(data) != ‘undefined’) {
data.unshift(‘request’);
data = Xml.parseJS(data).toXmlString();
} else {
data = ‘’;
}
var headers = {
“Authorization” : “Basic “ + this._credentials,
“Accept” : “application/json”,
};
var options = {
“contentType” : “application/xml”,
“method” : restVerb.toLowerCase(),
“payload” : data,
“headers” : headers
};
return UrlFetchApp.fetch(this._url + uri, options).getContentText(); //Xml.parse(UrlFetchApp.fetch(this._url + uri, options).getContentText()).getElement();
}

Making the calling from your own code


function getReport() {
// Loading Solve360Service library
// write here ..
var user = UserProperties.getProperty(USERPROPERTY_USER);
var token = UserProperties.getProperty(USERPROPERTY_TOKEN);
if (user == null || user.length == 0 || token == null || token.length == 0) {
throw new Error(‘Use Solve360 spreadsheet menu to set email and token first’);
}
// Configure service gateway object
Solve360Service.setCredentials(user, token);
var myContacts = Solve360Service.searchContacts([]);//getContactsCategories();
var myContactsJson = Utilities.jsonParse(myContacts);

….

Links

http://code.google.com/googleapps/appsscript/

http://norada.com/

http://static.solve360.com/gadgets/resources/js/Solve360Service.js

regards

Advertisement

Deja un comentario

Fill in your details below or click an icon to log in:

Logo de WordPress.com

You are commenting using your WordPress.com account. Log Out / Cambiar )

Twitter picture

You are commenting using your Twitter account. Log Out / Cambiar )

Facebook photo

You are commenting using your Facebook account. Log Out / Cambiar )

Connecting to %s

Seguir

Get every new post delivered to your Inbox.

Únete a otros 115 seguidores