I am interacting with a web service in my Titanium Appcelerator Project (with oAuth 2) and I need to make an HTTP POST request. I am successfully making the command with curl like this:
curl https://api.website.com/oauth/ -i -d "param=value&nextparam=goeshere" -H "Authorization: Basic hashgoeshere"That works. However when I try it in Appcelerator, none of my parameters get passed successfully, and since I haven't gotten that to work, I'm unsure whether I am passing the header correctly either. My titanium code is as follows:
xhr.validatesSecureCertificate = true; xhr.open("POST","https://api.website.com/oauth"); xhr.setTimeout(10000); xhr.setRequestHeader('Authorization', "Basic hashgoeshere"); //unsure whether I need the next line or not. I don't in curl //xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8"); xhr.send('{"param":"value","nextparam":"goeshere"}');I've debugged with the API server, and I'm getting the error that I would get if I sent no parameters, so obviously I'm doing something wrong. I just don't know what. Any help would be apprecaited!