• Register
0 votes
363 views

Problem :

Currently I am trying to display a JSON content using a API key. But I am unable to get a authentication.

I am facing below error in my JsonObject:

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

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

7 5 2
3,870 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

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

You need to check the URL.

Also it looks like a simple answer is a right one - your result is not the valid JSON string. Please see JSON.org website for more details on what the JSON should look like.

Check out JSON Parser Online  I know it is very useful when you are working with JSON.

It is very strange that you are requesting the JSON, and it is not returning it properly.

OR

Remove your docType from API. and you must set content Type as Application/json . (because a text/html will not be read as json . so you were seeing the error.)

9 7 4
38,600 points

Related questions

0 votes
1 answer 445 views
445 views
Problem : I am very new to Spring Boot. I am learning to write code in Spring Boot. I have written my first Spring Boot code as below @RequestMapping(value = "/bar/foo", method = RequestMethod.GET) public MyResponseEntity<foo> foo() { Foo model; ... return ... .core</groupId> <artifactId>jackson-databind</artifactId> <version>2.4.3</version> </dependency> How can I fix above Spring Boot exception?
asked Feb 29, 2020 mphil 2.3k points
0 votes
1 answer 62 views
62 views
Problem : According to the following documents: https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline.html I have the oauth user token and the user token secret, plus I have my app credentials... The docs state that the ... is supported by Twitter, but how should I include it in the get requests for screen names those are not publicly accessible?
asked Nov 25, 2019 alecxe 7.5k points
0 votes
1 answer 391 views
391 views
Problem : I am facing error &ldquo;Expecting value: line 1 column 1 (char 0)&rdquo; when trying to decode the JSON.The URL I use for a API call works fine in a browser, but gives above error when done through the curl request. The error happens at the return simplejson.loads(response_json)
asked Jan 20, 2020 jwilliam 3.9k points
0 votes
1 answer 41 views
41 views
Can someone explain me why i am seeing this error that told me to use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 path $. How to solve it and what is reason behind this error?
asked Sep 14, 2020 Daniel Anderson 4k points
0 votes
1 answer 24 views
0 votes
1 answer 24 views
24 views
Problem: I am trying to create one app in which I need to send data from mobile to server. However my problem is data is getting reflected on website only when the server is online or Up.when the server is offline then I get response as 400 or 502 and so my data is ... my data when the server becomes online.I am very new in android so I don't have any idea how to insert this json into a sqlite.
asked Sep 4, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 31 views
31 views
Problem: Few days ago I was trying to get my data from MySQL PHP to the Android with the help of JSON Object but somehow it is not working for me. I was researching on my issue but the solution which I found online did not really help me. I am having the array ... but after working on it for so long I was still unsuccessful. Can someone who knows PHP and JSON try to help me in resolving my issue?
asked Aug 4, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 11 views
11 views
I was working on that. I just want to know how to do that?
asked Nov 30, 2020 TeamScript 9.2k points
0 votes
1 answer 11 views
11 views
Hello all! I&rsquo;m newbie programmer. Currently I&rsquo;m working with jSON to fetch some data for my new project.But I&rsquo;ve stucked with some problems. I&rsquo;m trying using getJSON method to get value of it. Need help. Any help will be appreciated. What I want to get is jobDescription&rsquo;s value. {"JobData":{"JobDescription":"Cashier Wanted","JobSearch":"Search"}}
asked Oct 27, 2020 mrain 120 points
0 votes
1 answer 7 views
7 views
Problem Hey, I want to ask you something, how to get specific data from a particular column from datatable.let me describe you the full question. I am working on a project application restaurant menu . My app has a sqlite table which has three columns. Those are "id", "category", "item_name"    Category ... null) {                 cursor.moveToFirst();             }             return cursor;
asked Jan 4 chris jordan 2.2k points