jaytech123 / android-query

Automatically exported from code.google.com/p/android-query
0 stars 0 forks source link

post to GCM - response invalid JSON? #175

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
uaing v0.26.7, trying to POST @ google cloud messaging

a)the post must contain headers like :
"Authorization", "key=yourkeyhere"
"Content-Type", "application/json"

the only way I found (searching internet) is to create a 
AjaxCallback<JSONObject> cb;

-set the url
-set the header 
-set the params

always the response is code - 400 writes :
JSON_PARSING_ERROR: Unexpected character (d) at position 0.
or
JSON_PARSING_ERROR: Unexpected token END OF FILE at position 0

shot : http://i.imgur.com/vFF3hJL.png

----------

the post parameters must be like (PHP) :
    $fields = array('registration_ids' => $registrationIDs, 
            'data' => array("message" => $message), );

array['registration_ids'] = 12312
array['data'] = array['message'] = "hello"

I tried post parameters via :
-Map<String, Object> params = new HashMap<String, Object>();
-List<NameValuePair> pairs = new ArrayList<NameValuePair>() + 
UrlEncodedFormEntity
-HashMap<String, JSONObject>

no idea.... how to..

keep in mind when there is no valid header, returns 401 Authorized

Original issue reported on code.google.com by yotag...@gmail.com on 19 Feb 2014 at 6:22

GoogleCodeExporter commented 8 years ago
solved, with AQuery.POST_ENTITY

Original comment by yotag...@gmail.com on 22 Feb 2014 at 11:46