Kong / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
http://kong.github.io/unirest-java/
MIT License
2.6k stars 594 forks source link

Minor, but confusing, issue #234

Closed hethcox closed 5 years ago

hethcox commented 6 years ago

I was building out my REST call to mailgun and I used "apiKey" instead of "api" (started with a different example) thus: .basicAuth("api", apiKey) Instead of complaining about a missing key I got: Caused by: org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1]

It took a while to sort-out what was wrong. I'm posting this in hopes of saving future headaches.

ryber commented 6 years ago

This is because the library fails to parse the error message that returned from the service to json. It expects everything, including the errors to be JSON. I'm currently working on fixing this in a fork as this project is dead https://github.com/OpenUnirest/unirest-java/issues/10

ryber commented 5 years ago

Hello, this should be resolved or addressed in Unirest 2. Please see the upgrade guide for important changes.