The Database Hub | Back4App
The Database Hub | Back4App
How it works
  • Log In
  • Sign Up

  1. Back4App
  2. World Continents, Countries, and Cities
Public

1210
5630
1210
5630
  • DatabaseDatabase
  • GraphQL API PlaygroundAPI Playground
  • Get Started GuideGet Started
  • IssuesIssues
  • ContributorsContributors
  • Database
    Database
    GraphQL API Playground
    API Playground
    Get Started Guide
    Get Started
    Contributors
    Contributors

  1. IssueOpen
  2. Trying to get the cities and I get unauthorized error

New IssueNew

ivanlidor98 commented this issue on Sep 2020

in the website and on my client, when I try to get the cities I get an error. in your website it says: "It was not possible to load the output: Something wrong happened in our side. Please try again later." all the time at the end and on the client I just get an error like that: {"error":"unauthorized"}

davimacedo commented this issue on Sep 2020

Could you please share the query that you are trying to execute?

ivanlidor98 commented this issue on Sep 2020

this is the code the website generated for me: (I'm trying to get the cities from the database)

(new Thread(new Runnable() { @Override public void run() { try { URL url = new URL("https://parseapi.back4app.com/classes/Continentscountriescities_City/CityList?keys=name"); HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); urlConnection.setRequestProperty("X-Parse-Application-Id", "0saXVLkePf7VXrftKvcAwqeffeNbxHUAA1eBbOh7"); // This is your app's application id urlConnection.setRequestProperty("X-Parse-REST-API-Key", "RHresVbGu9orrnXhwhTqjPmRCWfIVKGiOP8i5jIi"); // This is your app's REST API key try { BufferedReader reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); StringBuilder stringBuilder = new StringBuilder(); String line; while ((line = reader.readLine()) != null) { stringBuilder.append(line); } JSONObject data = new JSONObject(stringBuilder.toString()); // Here you have the data that you need Log.d("MainActivity", data.toString(2)); } finally { urlConnection.disconnect(); } } catch (Exception e) { Log.e("MainActivity", e.toString()); } } })).start();

adavimacedo commented this issue on Sep 2020

Where you see https://parseapi.back4app.com/classes/Continentscountriescities_City/CityList?keys=name could you please try to change to https://parseapi.back4app.com/classes/Continentscountriescities_City?keys=name? It is strange it is generating for you with CityList at the end. Could you please double check and confirm?

adavimacedo commented this issue on Sep 2020

Also... I recommend you to generate a new rest key for your app (you can do that under Dashboard -> Server Settings -> Core Settings) since you made it public.

Please enter a comment for this issue.