I need to send the json array as a parameter through the post method from Android ... and the form of feedback Get jsonarray in ..
What should be the conversion of the referenced request mentioned in Java? .. ??
curl-H "X-Opansarf Service: Opanil. Search" --deta 'Osrf-msg = [ "Thredtres": 0, "payload": { "__ C": " Osarf method "," __ P ": {" Params ":" 30007004981493 "," method ":" open- Ils.search.biblio.find_by_barcode "}}," type ":" REQUEST "," locale ":" en I have done it like this:
Pre> HTTPPRAMPPRs = new basic HTTPPARM (); HTTP Client Client = New Default HTTP Client (HPPARM); HttpPost httpost = New HTTP Post ("http: //" + Hostname + "/ OSRF-HP-Translator"); // httpost.setHeader ("Accept", "App / JS"); // httpost.setHeader ("content-type", "app / jsan"); Httpost.setHeader ("X-OpenSRF-Service", "OpenLink.earch"); Println ("2"); JSONObject Data = New JSONObject (); JSONObject _p = new JSONObject (); JSONObject _p1 = new JSONObject (); JSONObject osrfmsg = new JSONObject (); HttpResponse response = null; {_p.put ( "params", bookid), try "" 30007004981493 "_p.put (" method "," open- ils.search.biblio.find_by_barcode ") or; JSONObject payload = new JSONObject (); payload. Put ( "_ C", "Osarf method"); Pelodkput ( "_ P" _p); _p1.put ( "ThreadTrace", 0); _plkput ( "payload", payload); _plkput ( "locale", "en-US"); _p1.put ( "" type "," request); osrfmsg.put ( "_ C", "osrfMessage"); osrfmsg.put ( "_ p" _ p1) ; data.put ( "osrfmsg", osrfmsg);} catch (Jesnaksapshn e) {// Two-Auto-generated catch block Ikprintstakstres ();} JSONArray osrfmsg2 = new JSONArray (); osrfmsg2.put (osrfmsg) ; Httpost.getParams () setParameter ("osrf-msg", osrfmsg2). Response = client.execute (ht (String) = empty; (StringBiller Reader = New Busted Reader (New interstitial reader) .Antita () GetContent (), "UTF-8"); StringBillilder Builder = New StringBuilder (); (string = Reader. Readline ())! = Null;) {builder.append (line) .append ("\ n");} JSontokener tokener = New JSONTokener (Builder.ststring ()); JSONArray finalResult = new JSONArray (tokens); But I'm not able to get the JSON array ...
Is there any other method?
After
By the way, you are creating a JSONObject as a parameter,
Try using
JSONArray as your payload object.
JSONArray payload = new JSONArray (); And work with a collection. Hope they help. Whatever your referral type you send is not JSON, it is encoded form
Comments
Post a Comment