java.lang.IllegalArgumentException: Illegal character in query at index 59 - java

What i am doing:
I am trying to make a reverse geocoding in android
I am getting error as::
java.lang.IllegalArgumentException: Illegal character in query at index 59: http://maps.google.com/maps/api/geocode/json?address=Agram, Bengaluru, Karnataka, India&sensor=false
NOte: that request gets a json response in browser but not from my class below
This line is giving this error::
HttpGet httpget = new HttpGet(url);
JSONfunctions.java
public class JSONfunctions {
public static JSONObject getJSONfromURL(String url) {
InputStream is = null;
String result = "";
JSONObject jArray = null;
// Download JSON data from URL
try {
HttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget);
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, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
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());
}
try {
jArray = new JSONObject(result);
} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}
return jArray;
}
}

Use URLEncoder.encode() to encode the value of your address parameter "Agram, Bengaluru, Karnataka, India" before putting it in the URL string so that it becomes something like
http://maps.google.com/maps/api/geocode/json?address=Agram,+Bengaluru,+Karnataka,+India&sensor=false
i.e. spaces changed to + and other special octets represented as %xx.
Browsers do smart URL encoding for strings entered in the address bar automatically so that's why it works there.

Build your url like,
final StringBuilder request = new StringBuilder(
"http://maps.googleapis.com/maps/api/geocode/json?sensor=false");
request.append("&language=").append(Locale.getDefault().getLanguage());
request.append("&address=").append(
URLEncoder.encode(locationName, "UTF-8"));

I am using httpclient 4.3.3
String messagestr = "Welcome to Moqui World";
String url="http://my.example.com/api/sendhttp.phpauthkey="+URLEncoder.encode("17djssnvndkfjb110d3","UTF-8")+"&mobiles=91"+URLEncoder.encode(contactNumber,"UTF-8")+"&message="+URLEncoder.encode(messagestr,"UTF8")+"&sender="+URLEncoder.encode("WMOQUI","UTF-8")+"&route=4";
HttpClient client = HttpClientBuilder.create().build();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
It's working fine for me. I hope this may help you.

Related

Android application doesn't read entire HTTP response

I have written a web-service in Java. This web-service is hosted in TOMCAT. I am returning a JSON string. The JSON string is as follows:
accountDetailsNodes = [{mobileNumber=01948330292, errorMessage=null, customerCode=59744000002, photo=a string of 35536 charaters , accountOpenDate=null, errorFlag=N, customerNumber=4, customerName=Md. Saifur Hossain , accountID=2, accountTypeId=13, accountTypeDescription=Savings Account, customerPointId=1, balance=100000037640.50, accountTile=Md. Saifur Hossain}]
The length of the JSON string is 32613. But the full response is not coming to android apps. I think there may be some limitation on sending response from Tomcat. How can I overcome this limitation of Tomcat?
Updated:
This is my code to generate JSON.
try {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
JSONObject json = new JSONObject();
CashDepositDao dao = new CashDepositDao();
for (CashDepositModel bo : dao.getAccountDetals(accountNo,branchCode)) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("accountTile", bo.getAccountTitle());
map.put("accountOpenDate", bo.getAccountOpenDate());
map.put("mobileNumber", bo.getMobileNumber());
map.put("balance", bo.getBalance());
map.put("accountTypeId", bo.getAccountTypeID());
map.put("accountTypeDescription", bo.getAccountTypeDescription());
map.put("accountID", bo.getAccountID());
map.put("customerNumber", bo.getCustomerNumber());
map.put("customerCode", bo.getCustomerCode());
map.put("customerName", bo.getCustomerName());
map.put("customerPointId", bo.getCustomerPointID());
map.put("photo", bo.getPhoto());
map.put("errorMessage", bo.getErrorMessage());
map.put("errorFlag", bo.getErrorFlage());
list.add(map);
json.put("accountDetailsNodes", list);
}
System.out.println("accountDetailsNodes = " + list);
response.addHeader("Access-Control-Allow-Origin", "*");
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().print(json.toString());
response.getWriter().flush();
// System.out.println("Response Completed... ");
} catch (Exception ex) {
Logger.getLogger(SourecAccountDetailsSV.class.getName()).log(Level.SEVERE, null, ex);
}
Sending And Getting response from Mobile App:
I am sending and getting the response using the following code:
public JSONObject makeHttpRequest(String url, String method,
List<NameValuePair> params) {
// Making HTTP request
try {
// check for request method
if(method == "POST"){
// request method is POST
// defaultHttpClient
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(params));
HttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}else if(method == "GET"){
// request method is GET
DefaultHttpClient httpClient = new DefaultHttpClient();
String paramString = URLEncodedUtils.format(params, "utf-8");
url += "?" + paramString;
HttpGet httpGet = new HttpGet(url);
HttpResponse httpResponse = httpClient.execute(httpGet);
HttpEntity httpEntity = httpResponse.getEntity();
is = httpEntity.getContent();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
json = sb.toString();
System.out.println(json);
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
// try parse the string to a JSON object
try {
jObj = new JSONObject(json);
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
}
// return JSON String
return jObj;
}
I have printed the string received in this method . Surprisingly, the full string is not received in this method.
How can I overcome this limitation of tomcat ?
Tomcat can send arbitrary length strings, and even if there was a limit, it wouldn't be measured in kilobytes but in orders of magnitude more. There is no tomcat limitation that you need to overcome. If your browser receives the full string, so can any other app.
As you're using json.toString() anyways, you could explicitly set the Content-Length header and see if this makes a difference. Stop worrying about Tomcat and double check if your Android App has some problems parsing a json response of this size, or if any network component in between limits your response in some way.
Edit: It's not Tomcat's problem, it's on the Android side and your answer is in the comments to the question.
The first problem is in what's proposed as "duplicate" question: You must not compare String with == as you do. Add else System.out.print("unexpected"); to your first if/else block to illustrate.
The second problem is that we have no clue where you get is from. As it looks now, it could be overridden by parallel requests (it's probably a class member?) - or due to the wrong string comparison never be initialized at all (leading to your problem that you can't see any content at all on the Android side, despite tomcat sending it). Make it a local variable, as proposed by EJP in his/her comment.
I think there may be some limitation on sending response from Tomcat.
There isn't.
How can I overcome this limitation of Tomcat?
There is no such limitation.
I am sending and getting the response using the following code:
public JSONObject makeHttpRequest(String url, String method,
List<NameValuePair> params) {
// Making HTTP request
try {
// check for request method
if(method == "POST"){
Here you are incorrectly comparing strings. You should use equals(), not ==.
// ...
}else if(method == "GET"){
Ditto.
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
Here you are using is which may not have been initialized at all. It appears to be a member variable, so it is probably still null, so at this point I would expect a NullPointerException. is should of course be a local variable in this method.
I have printed the string received in this method. Surprisingly, the full string is not received in this method.
What is surprising is that anything is received, if that's what you're claiming. I would have expected an NPE.

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);
........
.....
}

How send a json to server

I have a json that will be send to server in "Post".
There are parameters in json for 3 images to upload on server using multipart. I have no additional parameter to send it Multipart.
When I try it "PostMan" app of chrome to test it.
Here are 2 cases-
case 1:- select "raw" option in body & set content type "application json" in POSTMAN
Then all data had send to server expect images.
Case 2: Select "form-data" option in PostMan.
I have only to send some part of Json like images, certificates, venue, address, contact, achievement, level, at_home, certified, but unable to failed "coach_free_batch","coach_session" & "sports" section of json.
Please provide solution to upload all fields on server
Either idea to send "sports","coach_free_session" in second case by Postman or any other idea
Json
{"coach_free_batch":[{"sport_id":"10","batch_timing":{"end_time":"1:51 PM","start_time":"12:51 PM"},{"end_time":"11:51 AM","start_time":"10:51 AM"},{"end_time":"1:51 PM","start_time":"11:51 AM"}]},
{"sport_id":"4","batch_timing":[{"end_time":"1:52 PM","start_time":"12:52 PM"},
{"end_time":"3:52 PM","start_time":"2:52 PM"},{"end_time":"3:54 PM","start_time":"2:52 PM"}]}],
"coach_session":[{"timing":"2 Hour","rate":"24"},{"timing":"1 Hour","rate":"40"},
{"timing":"3 Hour","rate":"70"}],
"achievement":" national level",
"level":"Competitive","user_token":"XJnQCAz1ssuUCjgHtFs6","at_home":"1",
"sports":[{"user_sports_label_id":"7","sport_id":"2"},{"user_sports_label_id":"10","sport_id":"3"},
{"user_sports_label_id":"3","sport_id":"4"}],
"images":[{"image":"xxx"},
{"image":"xxx"}],
"experience":" more than 2 year","venue":"address","contact":"8236968542",
"certificates":[{"certificate":"certificate1"},{"certificate":"certifocate2"},{"certificate":"certificate3"}]}
Method for send Data as raw
public static String sendDataInJSONFormat(String url, String json) {
// initialize
InputStream is = null;
String result = null;
String url1 = "";
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
httppost.setHeader("Content-Type",
"multipart/form-data; application/json; charset=UTF-8;text/plain");
HttpParams httpParameters = new BasicHttpParams();
int timeoutSocket = 25000;
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
StringEntity se = new StringEntity(json.toString(), "UTF-8");
httppost.setEntity(se);
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());
e.printStackTrace();
}
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "UTF-8"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
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());
e.printStackTrace();
}
return result;
}

Connect Android App to MySQL db through PHP/JSON

I have a MySQL database with one unique table: geopoints, that has 3 columns: id, lat and long, and this table is filled up with 4 entrys already, 4 values of lat and long (1E6 because its to use on a mapview).
My objective is to mark on a mapview all these 4 geopoints dynamicly using a php script that generates json array, and with a httpPost etc...
This is the code I have so far:
getjson = (Button) findViewById(R.id.button1);
getjson.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
JSONArray jArray;
String result = null;
InputStream is = null;
StringBuilder sb = null;
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();//Whats this for?
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(
"http://????????.com/????/getGeopoints.php");
HttpResponse response = httpclient.execute(httpPost);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpEntity entity = response.getEntity();
is = entity.getContent();
} catch (Exception e) {
Log.e("log_tag", "Error connecting to http " + e.toString());
}
try {
BufferedReader reader = new BufferedReader(
new InputStreamReader(is, "iso-8859-1"), 8);
sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result = sb.toString();
} catch (Exception e) {
Log.e("log_tag", "Error converting " + e.toString());
}
try {
jArray = new JSONArray(result);
for (int i = 0; i <= jArray.length(); i++) {
JSONObject json_data = jArray.getJSONObject(i);
Log.i("log_tag", "id: " + json_data.getInt("id")
+ ", latitude: " + json_data.getInt("lat")
+ ", longitude: " + json_data.getInt("long"));
}
} catch (JSONException e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}
}
});
This is the php file:
<?php
mysql_connect("?????.com", "username", "password");
mysql_select_db("database_name");
$q = mysql_query("SELECT * FROM geopoints");
while ($e = mysql_fetch_assoc($q))
$output[] = $e;
print(json_encode($output));
mysql_close();
?>
I have this file running right because as I enter the url on a browser it generates the exact json array with the exact information I want.
There is only think I don't understand, what's HttpEntity for? Because I followed up a tutorial, and in there it uses an array with information to filter from the db, as I don't want to filter any info (I want all the database table entrys, not just one or two) I just leaved it blank.
What's wrong with my code?
The error I get in logcat is all the catch messages "11-29 12:47:29.662: E/log_tag(898): Error connecting to http Http android.os.NetworkOnMainThreadException".
android.os.NetworkOnMainThreadException
android >= 3.0 does not allow Network request on main UI thread. you need to use AsyncTask to call network request.
That's because you're are blocking the main UI thread. Try to use AsyncTasks for Http requests.

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":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JmpCWuNU3WPmGQhNGdytMVPgqIFb6oQqMx0BU+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.json.JSONException: Value {"image":"\/9j\/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP\/sABFEdWNreQABAAQAAAAeAAD\/4QMpaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI\/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjAtYzA2MCA2MS4xMzQ3NzcsIDIwMTAvMDIvMTItMTc6MzI6MDAgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzUgV2luZG93cyIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpGQ0E3OUQyRDlDQkYxMUUxODMyQThCQTQ0RjhFMDFBRiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpGQ0E3OUQyRTlDQkYxMUUxODMyQThCQTQ0RjhFMDFBRiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjpp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LoQI4ZGM8aHKeAS0joq8t2pZgrXHMZw2lNmtHiBdvIppPn0UYc3juHq3btHGrpvL4lV9bSi\/ZdonITqxFqRtiCEeC17eIZwc3j1uK6c6kNkLn8nQSN0ZDrp0Wh7pG6W2smQYqnYDcW2xZtrAYZIr+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