0

I have a web-service that reply at some get request, something like this: http://developer.echonest.com/api/v4/artist/reviews?api_key=N6E4NIOVYMTHNDM8J&id=ARH6W4X1187B99274F&format=json&results=1&start=2 if a parameter in the request is wrong: http://developer.echonest.com/api/v4/artist/reviews?api_key=N6E4NIOVYMTHNDM8J&id=ARH6W4X1187B99274F&format=json&results=1&start=WRONG-STRING the server reply with a 400 and some json explain what is went wrong.

Now in clojure I want to read the json to know exactly what is went wrong, i tried with (clojure.java.io/reader wrong-url) but it thrown an exception

Server returned HTTP response code: 400 for URL:
http://developer.echonest.com/api/v4/artist/reviews? api_key=N6E4NIOVYMTHNDM8J&id=ARH6W4X1187B99274F&format=json&results=1&start=e1 [Thrown class java.io.IOException]

How can i read the json ?

Siscia
  • 1,421
  • 1
  • 12
  • 29
  • My big problem is that clojure.java.io/reader thrown an exception because it get the 400 error, but after that (i assume) i get the json that i need... The problem is not parse the json is **get** the json after the 400 – Siscia Apr 23 '12 at 22:44

1 Answers1

0

Sometimes I just really want to see what's going over the wire, and in those situations I fire up Wireshark, a network packet analyser. Here's how I'd use it in this case (but it's a powerful and flexible piece of software, you can do lots of nifty stuff with it):

  1. Start it up
  2. select Capture->Options (Ctrl-K)
  3. select the network interface you want to capture traffic for
  4. enter host developer.echonest.com as the capture filter
  5. hit the start capture button

Then interact with your service at echonest.com - you'll see packets coming in in Wireshark's window. When you're done, go back to Wireshark and hit Capture->Stop (Ctrl-E).

In the list of packets, find the one that starts with GET /api/v4/arist/..., right-click and select "Follow TCP Stream" — That will show you exactly what is being sent and received.

Gert
  • 3,839
  • 19
  • 22