I'm developing an Android app and I have integrated Scribe library to make http connection with OAuth1.0 with Magento. My problem is that I need to send a request with a parameter into body but without a key. Now I make login correctly and I have my Token authorized, I get products from server, categories, blah blah... but I cannot make checkout because always I get code "401 Authorization require". I think that the problem could be by the parameter in the body.
My code:
...
@Override
protected String doInBackground(String... json) {
String result = null;
org.scribe.model.Response response = null;
String url = Global.BASE_URL + "cart/1";
if(Global.TOKEN_AUTHORIZED != null) {
OAuthRequest request = new OAuthRequest(Verb.POST, url);
//I only need insert a json into body without key
request.addBodyParameter(<I don't need a key>, json[0]);
Global.OAUTH_SERVICE.signRequest(Global.TOKEN_AUTHORIZED, request);
response = request.send();
}
if(response != null && response.getCode() == 200) {
result = response.getBody();
} else {
result = "ERROR";
}
return result;
}
...
How I put only a parameter in the body but without key, value?
Thanks in advance :)
I found the solution:
Now I get a response with code 200 :)
if(Global.TOKEN_AUTHORIZED != null) {
OAuthRequest request = new OAuthRequest(Verb.POST, url);
request.addHeader("Content-Type", "application/json");
request.addPayload(params[0]);
Global.OAUTH_SERVICE.signRequest(Global.TOKEN_AUTHORIZED, request);
response = request.send();
}
I hope to help somebody :)