Android volley request using curl command -
i want pass content web server on format
curl -h "content-type:application/json" -x post -d {"email":"someone@example.com","first_name":"fname","last_name":"lname","password":"pass123"}' 192.xxx.xxx.xxx:1111/register_user
this how need pass values server. can 1 me. how possible using volley? in advance
yes can in way
jsonobjectrequest jsonrequest = new jsonobjectrequest(request.method.post, "192.xxx.xxx.xxx:1111/register_user", new jsonobject("{"email":"someone@example.com","first_name":"fname","last_name":"lname","password":"pass123"}"), new response.listener<jsonobject>() { @override public void onresponse(jsonobject jsonobject) { //call successful } }, new response.errorlistener() { @override public void onerrorresponse(volleyerror volleyerror) { //error occur } }) { @override public map<string, string> getheaders() throws authfailureerror { map<string, string> params = new hashmap<>(); params.put("content-type", "application/json"); params.put("accept", "application/json"); params.put("accept-encoding", "utf-8"); return params; } }; jsonrequest.setretrypolicy(new defaultretrypolicy( my_socket_timeout_ms, defaultretrypolicy.default_max_retries, defaultretrypolicy.default_backoff_mult)); mrequestqueue.addtorequestqueue(jsonrequest);
Comments
Post a Comment