send json array as post parameter from android - java

I need to send json array as a paramater via post method from android ...and receive jsonarray as response..
what should be the conversion of below mentioned request in java..??
curl -H "X-OpenSRF-service: open-ils.search" --data 'osrf-msg=[{"__p" : {"threadTrace" : 0, "payload" : { "__c" : "osrfMethod","__p" : { "params" :"30007004981493","method" : "open-ils.search.biblio.find_by_barcode"}},"type" : "REQUEST","locale" : "en-US"},"__c" : "osrfMessage"} ]' http://localhost/osrf-http-translator
i have done it like this..
HttpParams httpParams = new BasicHttpParams();
HttpClient client = new DefaultHttpClient(httpParams);
HttpPost httpost = new HttpPost("http://"+hostname+"/osrf-http-translator");
// httpost.setHeader("Accept", "application/json");
// httpost.setHeader("Content-type", "application/json");
httpost.setHeader("X-OpenSRF-service", "open-ils.search");
System.out.println("2");
JSONObject data = new JSONObject();
JSONObject _p = new JSONObject();
JSONObject _p1 = new JSONObject();
JSONObject osrfmsg = new JSONObject();
HttpResponse response = null;
try {
_p.put("params",bookid);//"30007004981493"
_p.put("method","open-ils.search.biblio.find_by_barcode");
JSONObject payload = new JSONObject();
payload.put("_c", "osrfMethod");
payload.put("_p", _p);
_p1.put("threadTrace",0);
_p1.put("payload", payload);
_p1.put("locale","en-US" );
_p1.put("type", "REQUEST");
osrfmsg.put("_c","osrfMessage");
osrfmsg.put("_p",_p1);
data.put("osrf-msg",osrfmsg);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JSONArray osrfmsg2=new JSONArray();
osrfmsg2.put(osrfmsg);
httpost.getParams().setParameter("osrf-msg",osrfmsg2);
response = client.execute(httpost);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
StringBuilder builder = new StringBuilder();
for (String line = null; (line = reader.readLine()) != null;)
{ builder.append(line).append("\n"); }
JSONTokener tokener = new JSONTokener(builder.toString());
JSONArray finalResult = new JSONArray(tokener);
but i'm not able to get the json array...
is there any other method?

Well you are constructing a JSONObject as the parameter,
try using
JSONArray as your payload object.
JSONArray payload = new JSONArray();
And work with a collection.
Hope that helps.
Also your context type that you send is not JSON, it is form encoded

Related

Can not find the Json object (Using org.json)

Microsoft Academic provided an API to get some general information from Microsoft academic. The response type is a Json Object. Using org.Json and following code, I have tried to read the response object but I have failed (need to download these jars + common-logging and common-codec) :
URIBuilder builder = new URIBuilder("https://api.projectoxford.ai/academic/v1.0/evaluate?");
builder.setParameter("expr", "Composite(AA.AuN=='jaime teevan')");
builder.setParameter("count", "100");
builder.setParameter("attributes", "Ti,CC");
URI uri = builder.build();
HttpGet request = new HttpGet(uri);
request.setHeader("Ocp-Apim-Subscription-Key", "Your-Key");
HttpClient httpclient = HttpClients.createDefault();
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null) {
JSONObject obj = new JSONObject(entity);
JSONArray arr = obj.getJSONArray("entities");
for (int i = 0; i < arr.length(); i++){
String post_id = arr.getJSONObject(i).getString("Ti");
System.out.println(post_id);
}
System.out.println(EntityUtils.toString(entity));
}
Which returns the following exception:
Exception in thread "main" org.json.JSONException: JSONObject["entities"] not found.
at org.json.JSONObject.get(JSONObject.java:471)
at org.json.JSONObject.getJSONArray(JSONObject.java:618)
How to fix this?
EDIT
Although it is easy to see an example of the response from the link I provided at the beginning of my question (Microsoft Academic), but for ease of readers I show it in here:
{
"expr": "Composite(AA.AuN=='jaime teevan')",
"entities":
[
{
"logprob": -15.08,
"Ti": "personalizing search via automated analysis of interests and activities",
"CC": 372,
},
{
"logprob": -15.389,
"Ti": "the perfect search engine is not enough a study of orienteering behavior in directed search",
"CC": 237,
}
]
}
Seems like the problem to me is you are not converting your response to string , you need to convert your response to string before passing it to JSONObject
HttpEntity entity = response.getEntity();
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
entity.writeTo(os);
} catch (IOException e1) {
}
String contentString = new String(os.toByteArray());
or other way is
InputStream instream = entity.getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
String contentString = sb.toString(); // you can pass sb.toString() directly to jsonobject as well
and now pass contentString to JSONObject
JSONObject obj = new JSONObject(contentString);
JSONArray arr = obj.getJSONArray("entities");
Update : your can also use this which is also suggested by #Ömer Fadıl Usta
but i would strongly recommend to use HttpURLConnection for security and performance
Try to pass string JsonData to JSONObject :
if (entity != null) {
String jsonData = EntityUtils.toString(entity);
JSONObject obj = new JSONObject(jsonData);
........
.....
}

passing json reply from webservice to variables

i'm posting some data to a web service and i'm getting a json reply which i want to pass to a jsonobject.
The reply of the web service is:
{
"ValidateLoginResult": [
{
"ErrorMessage": "Wrong username pass",
"PropertyName": null
}
]
}
and i want to pass the error message and the property name to variables. I tried using JSONobject and JSONarray but didnt have any luck
HttpClient httpclient = new DefaultHttpClient();
// 2. make POST request to the given URL
HttpPost httpPost = new HttpPost(serverURL);
StringEntity se = new StringEntity(data);
httpPost.setEntity(se);
// 7. Set some headers to inform server about the type of the content
httpPost.setHeader("Accept", "application/json");
httpPost.setHeader("Content-type", "application/json");
// 8. Execute POST request to the given URL
HttpResponse httpResponse = httpclient.execute(httpPost);
// 9. Getting Reply
inputStream = httpResponse.getEntity().getContent();
...
...
JSONArray json = new JSONArray(convertInputStreamToString(inputStream));
JSONObject json_LL = json.getJSONObject(0);
String str_value=json_LL.getString("ErrorMessage");
You are getting response in JSONObject and you are trying to get it in JSONArray.. thats why you are getting error..
Try this way...
try {
JSONObject result = new JSONObject(response);
if(data.has("ValidateLoginResult"){
JSONArray array = result.getJSONArray("ValidateLoginResult");
for (int i = 0; i < array.length(); i++) {
JSONObject obj = array.getJSONObject(i);
String ErrorMessage= ""+obj.getString("ErrorMessage");
String PropertyName= ""+obj.getString("PropertyName");
}
}
} catch (JSONException e) {
e.printStackTrace();
}
OR
if you want one line answer..Try this..
// going directly to array object..
JSONObject result = new JSONObject(response).getJSONArray("ValidateLoginResult").getJSONObject(0);
String ErrorMessage= ""+result.getString("ErrorMessage");
String PropertyName= ""+result.getString("PropertyName");

Jsonexception - cannot be converted to JSONObject [duplicate]

This question already has answers here:
JSONException: Value of type java.lang.String cannot be converted to JSONObject
(14 answers)
Closed 8 years ago.
I know this exception is asked a million times before and I saw various post saying different suggestion and nothing worked for me yet.
I need to get some data from a url using httpget am giving a specific id along my url.
my output should looks likes this
{
"id": "35ZGXU7WQHFYY5BFTV6EACGEUS",
"createTime": "2014-04-11T12:52:26",
"updateTime": "2014-04-11T12:52:55",
"status": "Completed",
"transaction": {
"amount": {
"currencyCode": "GBP",
"total": 7.47
},
"qrcode": "189e8dad99908745o7439f8ffabdfipp",
"description": "This is the payment transaction description."
}
}
but due to something am getting this error
04-11 18:24:14.655: E/STATUS_ERR(30067): org.json.JSONException: Value com.mywallet.android.rest.MyWalletRestService$getStatus#41837fd0 of type java.lang.String cannot be converted to JSONObject
my code is as below
String line = null;
try{
BufferedReader in = null;
HttpGet request = new HttpGet();
URI website = new URI(url);
request.setURI(website);
request.setHeader("Accept", "application/json");
request.setHeader(AppConstants.PAYMENT_HEADER1, BEARER);
request.setHeader(AppConstants.content_type, AppConstants.application_json);
response = httpClient.execute(request);
in = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"), 8);
StringBuilder sb = new StringBuilder();
while ((line = in.readLine()) != null)
{
sb.append(line + "\n");
}
result = sb.toString();
JSONObject jObject = new JSONObject(toReturn);
}
if(jObject.has("error")){
RES_STATUS = AppConstants.FAIL;
}
else{
AppVariables.id = jObject.getString(AppVariables.id_);
AppVariables.createTime = jObject.getString(AppVariables.createTime_);
AppVariables.updateTime = jObject.getString(AppVariables.updateTime_);
AppVariables.status = jObject.getString(AppVariables.status_);
JSONObject oneObject = jObject.getJSONObject("transaction");
JSONObject twoObject = oneObject.getJSONObject("amount");
AppVariables.total = twoObject.getString("total");
AppVariables.currencyCode = twoObject.getString("currencyCode");
AppVariables.qrcode = oneObject.getString(AppVariables.qrcode_);
AppVariables.description = oneObject.getString(AppVariables.description_);
MWLog.e("AppVariables.id", AppVariables.id);
MWLog.e("AppVariables.createTime", AppVariables.createTime);
MWLog.e("AppVariables.updateTime", AppVariables.updateTime);
MWLog.e("AppVariables.status", AppVariables.status);
MWLog.e("AppVariables.currencyCode", AppVariables.currencyCode);
MWLog.e("AppVariables.total", AppVariables.total);
MWLog.e("AppVariables.qrcode", AppVariables.qrcode);
MWLog.e("AppVariables.des", AppVariables.description);
RES_STATUS = AppConstants.SUCCESS;
MWLog.e("BUYER", toReturn);
}
Use this function to get proper json response
public String getResponseBody(final HttpEntity entity) throws IOException, ParseException {
if (entity == null) {
throw new IllegalArgumentException("HTTP entity may not be null");
}
InputStream instream = entity.getContent();
if (instream == null) {
return "";
}
if (entity.getContentLength() > Integer.MAX_VALUE) {
throw new IllegalArgumentException(
"HTTP entity too large to be buffered in memory");
}
StringBuilder buffer = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(instream, HTTP.UTF_8));
String line = null;
try {
while ((line = reader.readLine()) != null) {
buffer.append(line.trim());
}
} finally {
instream.close();
reader.close();
}
return buffer.toString().trim();
}
How to use?
result= getResponseBody(response.getEntity());
result = sb.toString();
JSONObject jObject = new JSONObject(toReturn);
Shouldn't that be
result = sb.toString();
JSONObject jObject = new JSONObject(result);
You are trying to convert the String toReturn, which has invalid JSON data.
Here Amount is a JsonArray and you are trying to cast it in json object
JSONArray JsonArray2 = jsonobject.getJSONArray("amount");
Try this way

Request get in java for get source html

I have this request in Java but in the response i haven't all source, and Json object fail..
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(
"http://url?"+params);
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader(
new InputStreamReader(response.getEntity().getContent()));
StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}
String str = result.toString();
Document doc = Jsoup.parse(str);
JSONObject json = new JSONObject();
List<JSONObject> list = new ArrayList<JSONObject>();
Element elementsTable = doc.getElementById("shortlist");
this element shortlist can't find that..but if i go with my browser and get the source there is..where i'm wrong?
You can do it with Jsoup with simpler code ...
Connection connection = Jsoup.connect(url)
Document urlDoc = connection.get();
Elements domElement = urlDoc.getElementById(String id);

JSONArray and encoded image on Android tablet

I have a problem with my first Android App. I want to ask a PHP server for a name and image, using an cardid. This works well, but JSONArray throws an exception when I try to split up the long string I get. This is the method I use on the Android device:
public static Object[] getIdCardOwner(String card)
{
JSONArray jArray;
String result = null;
InputStream is = null;
StringBuilder sb=null;
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("cardid",card));
Object returnValue[] = new Object[2];
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(SERVER_URL);
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
Log.e("log_tag", "Error in http connection"+e.toString());
}
//convert response to string
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"utf-8"), 16);
sb = new StringBuilder();
sb.append(reader.readLine() + "\n");
String line="0";
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result=sb.toString();
}catch(Exception e){
Log.e("log_tag", "Error converting result "+e.toString());
}
//paring data
try{
jArray = new JSONArray(result);
JSONObject json_data=null;
for(int i=0;i<jArray.length();i++){
json_data = jArray.getJSONObject(i);
returnValue[0] = json_data.getString("name");
returnValue[1] = json_data.getString("image");
}
}
catch(JSONException e1){
Log.e("log_tag", "Error converting result "+e1.toString());
} catch (ParseException e1) {
e1.printStackTrace();
}
return returnValue;
}
This is the String result I get before the exception happens:
{"0":"4016612622","card":"4016612622","1":"Peter Poulsen","name":"Peter Poulsen","2":"\/9j\/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP\/sABFEdWNreQABAAQAAAAeAAD\/4QMpaHR0cDovL25zLmFkb2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OZyU6K7DAmwGRIWbz4nDheisiIxYYWLzoGdkYjV0Utknsp\/I3jgezAHURD\/VTIgwYdB+2UuuHtREX9fzUoywFZk1Djg6wQh8oQIdRgP3T2AVamwM3ZMncwRB1UhJfgXXRDAnCs02UGDF86ELJ5UDMMfuOfoqsZciobdxICPXAO8PRtSnUJECTqPuiEgYyySsaNVnJJeUm7OrfG4c6pBy4GWSdQV23o2YW7i0spwlEDH5LO8onfDUajoUwXghwoaNFaR10u+Fk2l+VBu6uW3rPNn\/AKBM9E6oz7Gsfo60jcyhE+IXJ2b5mQwCoxPiFa0c1nNnAx0KLoQI4ZGM8aHKeAS0joq8t2pZgrXHMZw2lNmtHiBdvIppPn0UYc3juHq3btHGrpvL4lV9bSi\/ZdonITqxFqRtiCEeC17eIZwc3j1uK6c6kNkLn8nQSN0ZDrp0Wh7pG6W2smQYqnYDcW2xZtrAYZIr+uEiMOdXadtJEz27KcYyMt2gIyPVN4vEpoidkREy1ICldIRgT1Kh7wLK2U7BkqlZieFbnJoklUTLdMlVVGfY8DBL0UoywlBTicKjEZu+qFF0IAmo1XGmzadDp9EOoWx3RxqMhVA04NOMvciWS27jI0SOByBgS10KvTEd2OqmDerlCYCcjonASPizBMrgAexTPGI3dkmV+sVOWyDKpffuLdl3k3OS5wMhULLskpKpFrByLX6qvHAD66oc2S9FOUC4bQaqtGdpZ0FSicJbEKUThMiGtjHQoOhIQ1+6hKYbGUbUbU5N11c5IRJrPuDT+7+qv1coSiM5VOsBzE9UqyudR3Vlh2TE5q8Gr\/2TE6u6VdzW1KzPft6lLJlI+RdECd2yxZyDMnslSJkWXACdFYppc6IJSbO01EJhiz\/RWBXtiyRYWwOqhs0qtIUYuubU0DCGUyauqe0KYoTNvVCfszP41BBbCEJmpCWuNU3WPmGQhNGdytMVPgqIFb6oQqMx0BU+T+6uUivoUISY0StMm8Q\/qqmTLywhClmtSeFxCFJYIQhIR\/\/Z"}
And this is the error I get:
05-14 14:13:00.723: E/log_tag(359): Error converting result org.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2smQYqnYDcW2xZtrAYZIr+uEiMOdXadtJEz27KcYyMt2gIyPVN4vEpoidkREy1ICldIRgT1Kh7wLK2U7BkqlZieFbnJoklUTLdMlVVGfY8DBL0UoywlBTicKjEZu+qFF0IAmo1XGmzadDp9EOoWx3RxqMhVA04NOMvciWS27jI0SOByBgS10KvTEd2OqmDerlCYCcjonASPizBMrgAexTPGI3dkmV+sVOWyDKpffuLdl3k3OS5wMhULLskpKpFrByLX6qvHAD66oc2S9FOUC4bQaqtGdpZ0FSicJbEKUThMiGtjHQoOhIQ1+6hKYbGUbUbU5N11c5IRJrPuDT+7+qv1coSiM5VOsBzE9UqyudR3Vlh2TE5q8Gr\/2TE6u6VdzW1KzPft6lLJlI+RdECd2yxZyDMnslSJkWXACdFYppc6IJSbO01EJhiz\/RWBXtiyRYWwOqhs0qtIUYuubU0DCGUyauqe0KYoTNvVCfszP41BBbCEJmpCWuNU3WPmGQhNGdytMVPgqIFb6oQqMx0BU+T+6uUivoUISY0StMm8Q\/qqmTLywhClmtSeFxCFJYIQhIR\/\/Z","2":"\/9j\/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP\/sABFEdWNreQABAAQAAAAeAAD\/4QMpaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI\/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm
Can anyone tell me, what I'm doing wrong and how to fix it?
Thanks in advance
Peter
The data they're supplying for json_data.getString("image") is not a string.
It's an image.
Check the JSON manually. It it's outputting image data then you need to get them to change the JSON. E.g. it should look like this:
"src": "Images/theImage.png",

Categories

Resources