Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8025263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:06:40+00:00 2026-06-04T23:06:40+00:00

Here I want to display the JSON content using API key. But I am

  • 0

Here I want to display the JSON content using API key. But I am unable to get the authentication.

I am getting the error in JsonObject:

org.json.JSONException: Value Authorization of type java.lang.String cannot be converted to JSONObject

In my android application, I just pass the API key and URL id to get the JSON response in the following URL. I display the JSON content using JSON array.

But if I:

public class AndroidAPiActivity extends Activity {

/*
 * FlickrQuery = FlickrQuery_url
 * + FlickrQuery_per_page
 * + FlickrQuery_nojsoncallback
 * + FlickrQuery_format
 * + FlickrQuery_tag + q
 * + FlickrQuery_key + FlickrApiKey
 */

String FlickrQuery_url = "http://192.138.11.9/api/interests/";
String FlickrQuery_per_page = "&per_page=1";
String FlickrQuery_nojsoncallback = "&nojsoncallback=1";
String FlickrQuery_format = "&format=json";
String FlickrQuery_tag = "&tags=";
String FlickrQuery_key = "&api_key=";

// Apply your Flickr API:
// www.flickr.com/services/apps/create/apply/?
   String FlickrApiKey = "f65215602df8f8af";

   EditText searchText;
   Button searchButton;
   TextView textQueryResult, textJsonResult;
   ImageView imageFlickrPhoto;
   Bitmap bmFlickr;

   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main);

       searchText = (EditText)findViewById(R.id.searchtext);
       searchButton = (Button)findViewById(R.id.searchbutton);
       textQueryResult = (TextView)findViewById(R.id.queryresult);
       textJsonResult = (TextView)findViewById(R.id.jsonresult);
       imageFlickrPhoto = (ImageView)findViewById(R.id.flickrPhoto);
       searchButton.setOnClickListener(searchButtonOnClickListener);
   }

   private Button.OnClickListener searchButtonOnClickListener
   = new Button.OnClickListener(){

 public void onClick(View arg0) {
  // TODO Auto-generated method stub
  String searchQ = searchText.getText().toString();
  String searchResult = QueryFlickr(searchQ);
  textQueryResult.setText(searchResult);
  String jsonResult = ParseJSON(searchResult);
  textJsonResult.setText(jsonResult);

  if (bmFlickr != null){
   imageFlickrPhoto.setImageBitmap(bmFlickr);
  }
 }};

   private String QueryFlickr(String q){

    String qResult = null;

    String qString =
      FlickrQuery_url
      + FlickrQuery_per_page
      + FlickrQuery_nojsoncallback
      + FlickrQuery_format
      + FlickrQuery_tag + q 
      + FlickrQuery_key + FlickrApiKey;

    HttpClient httpClient = new DefaultHttpClient();
       HttpGet httpGet = new HttpGet(qString);

       try {
  HttpEntity httpEntity = httpClient.execute(httpGet).getEntity();

  if (httpEntity != null){
   InputStream inputStream = httpEntity.getContent();
   Reader in = new InputStreamReader(inputStream);
   BufferedReader bufferedreader = new BufferedReader(in);
   StringBuilder stringBuilder = new StringBuilder();

   String stringReadLine = null;

   while ((stringReadLine = bufferedreader.readLine()) != null) {
    stringBuilder.append(stringReadLine + "\n");
    }

   qResult = stringBuilder.toString();

  }

 } catch (ClientProtocolException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 } catch (IOException e) {  
  // TODO Auto-generated catch block
  e.printStackTrace();
 }

       return qResult;
   }

   private String ParseJSON(String json){

    String jResult = null;
    bmFlickr = null;
    String key_id;
    String category;
    String subcategory;
    String title;
    String icon_image;

    try
     {
  JSONObject JsonObject = new JSONObject(json);
  JSONObject Json_photos = JsonObject.getJSONObject("interests");
  JSONArray JsonArray_photo = Json_photos.getJSONArray("interest");

  //We have only one photo in this exercise
  JSONObject FlickrPhoto = JsonArray_photo.getJSONObject(0);

  key_id = FlickrPhoto.getString("row_key");
  category = FlickrPhoto.getString("category");
  subcategory = FlickrPhoto.getString("subcategory");
   title = FlickrPhoto.getString("title");

  jResult = "\n key_id: " + key_id + "\n"
    + "category: " + category + "\n"
    + "subcategory: " + subcategory + "\n"
    + "title: " + title + "\n";

  bmFlickr = LoadPhotoFromFlickr(key_id, category, subcategory,title);

 } catch (JSONException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 }

    return jResult;
   }

   private Bitmap LoadPhotoFromFlickr(
     String key_id, String category, String subcategory,
     String title){
    Bitmap bm= null;

    String icon_image = null;
 //   String FlickrPhotoPath ="";
   String FlickrPhotoPath ="http://182.72.180.34/media/"+icon_image+".jpg";

    URL FlickrPhotoUrl = null;

    try {

  FlickrPhotoUrl = new URL(FlickrPhotoPath);

  HttpURLConnection httpConnection = (HttpURLConnection) FlickrPhotoUrl.openConnection();
  httpConnection.setDoInput(true);
  httpConnection.connect();
  InputStream inputStream = httpConnection.getInputStream();
  bm = BitmapFactory.decodeStream(inputStream);

 } catch (MalformedURLException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 } catch (IOException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 }

    return bm;
   }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T23:06:41+00:00Added an answer on June 4, 2026 at 11:06 pm

    Update:

    Based on the HTML response, I can tell you that this is not JSON. The response tells me that you have the incorrect URL for your web service.

    You need to check your URL.

    Extra Info / Previous Answer:

    It looks like the simple answer is the right one – your result is not a valid JSON string. See JSON.org website for details on what JSON should look like.

    Check out JSON Parser Online – I find its very useful when working with JSON.

    It is strange that you are requesting JSON, and it is not returning it properly – perhaps I have missed something.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am calling a rest webscript using Extjs with JSON,but unable to display on
I am using jquery to display results get by json object, here for image
I am brand new to actually using an API, getting the JSON data and
I want to display on my Wordpress website using MapMyFitness's API. It needs to
I am developing a php web site. Here I want to display twitter updates
I want display data from database in Listbox...Here is my code, It is not
I want to display a popup windo on my rails application... Here is exactly
here the sample case.. i want to display banner randomly by percentage based on
here is a link ! This link has Video and i want to display
I have a image here http://power.itp.ac.cn/~jmyang/funny/fun4.jpg and I want to display it in my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.