My iPhone app needs to call two different APIs. Identical calls produce different results:
httpClient.open("GET","http://api.timezonedb.com/?zone=Europe/Bucharest&format=json&key=[MY KEY]");
works just fine and gives the proper response from the targeted API, while
httpClient.open("GET","http://xurrency.com/api/usd/ron/1?key=[MY KEY]");
leads to an HTTP client error with a status = 500, meaning the sending server has an issue. Adding 'www.' to the second one makes no difference. This is completely puzzling (and very frustrating) to me. Anybody have an idea what might be going on here? Are there certain APIs Appcelerator just doesn't like?
1 Answer
Accepted Answer
Titanium's HTTPClient is just doing vanilla HTTP. It doesn't care what is on the other end.
My suspicion is that the server doesn't like the way the entire HTTP request is being presented. That's a lot more than just the URL. It's all the various headers that go with the request. User-Agent and Cookie would be the most likely culprit.
I would suggest making a request to the xurrency API using something like curl. Examine the headers closely. If curl can't make the request work, look into the reasons why.
If it does work, try to figure out the difference between curl's request and HTTPClient's request. You can use something like wireshark to capture the request/response.
But the short answer is that there's nothing inherently "wrong" with the Titanium HTTPClient. But it's default requests might be different from other clients in subtle ways that can cause a server to reject the request (or worse, bail out with a 500 error).
Your Answer
Think you can help? Login to answer this question!