Skip to content

Instantly share code, notes, and snippets.

@rfaisal
Created March 25, 2014 22:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfaisal/9773273 to your computer and use it in GitHub Desktop.
Save rfaisal/9773273 to your computer and use it in GitHub Desktop.
//table name todoitem and has id, text, and complete fields
var access_token = 'eyJhbGciOi...';
var xhr = Titanium.Network.createHTTPClient();
xhr.setTimeout(30000);
xhr.onload=function() {
Ti.API.info('Response by PATCH: '+this.responseText);
};
xhr.onerror= function() {
Ti.API.info('Error response: '+this.responseText);
};
xhr.open('PATCH', 'https://my_resource_auth_server.azure-mobile.net/tables/todoitem/123');
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("X-ZUMO-AUTH", access_token); // this is the magic line
xhr.send(JSON.stringify({
"text" : "hey there I am faisal",
"complete" : true
}));
//table name todoitem and has id, text, and complete fields
var access_token = 'eyJhbGciOi...';
var xhr = Titanium.Network.createHTTPClient();
xhr.setTimeout(30000);
xhr.onload=function() {
Ti.API.info('Response by POST: '+this.responseText);
};
xhr.onerror= function() {
Ti.API.info('Error response: '+this.responseText);
};
xhr.open('POST', 'https://my_resource_auth_server.azure-mobile.net/tables/todoitem');
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("X-ZUMO-AUTH", access_token); // this is the magic line
xhr.send(JSON.stringify({
"text" : "hey there I am faisal",
"complete" : true
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment