Created
March 25, 2014 22:53
-
-
Save rfaisal/9773273 to your computer and use it in GitHub Desktop.
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
//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 | |
})); |
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
//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