0

I'm having the issue that we can't get HTTP Response codes well from the Unity.WWW class. At the moment we are reading the following property for the statuscode after calling our REST API.

request.responseHeaders["STATUS"]

But some times this is empty. With a 401 response it is empty for example, the request does contain an error in this case, but the error is different on many devices. So you can't base anything on it.

Does someone know a way how to solve this?

NOTE: i can't use any plugins from the asset store as we need to distribute it. So i'm looking for a coding solution or another approach that will work with unity on Android and IOS.

Thanks in advance!

EDIT:

Hereby the errors returned on a 401 response, Example errors: "java.io.IOException: No authentication challenges found" or "java.io.IOException: Received authentication challenge is null"

Spons
  • 1,593
  • 1
  • 17
  • 46
  • Im not sure what you are asking (maybe show what you have tried so far). Anyways 1: the response headers arent available until after the www class has downloaded all data. 2: Are you testing the resulting response string? If this is your rest api, why not provide an intelligent response string you can parse. Also, what errors are you getting? – Rudolfwm Aug 16 '14 at 08:44
  • Thanks for responding @Rudolfwm, i was aware of point 1, but when the the response headers are returned, and the webservice returns an 401. It doesn't have a statuscode only an error text in request.Error starting with : "Java.io" (see edited post) The Java.io error changes depending on the java version(?). Now i wanted to know if getting the responseHeaders["Status"], is the right way? if yes, why it's not documented by unity? if not, which approach would you suggest? BTW the WWW call goes ok (normally). only has an error when 401 is returned. – Spons Aug 18 '14 at 06:29
  • check [this](http://stackoverflow.com/questions/17121213/java-io-ioexception-no-authentication-challenges-found) question out. Are you using authentication? (your server seems to think so)\. – Rudolfwm Aug 18 '14 at 12:34
  • Hero of the day. didn't test it yet. But this is certainly the reason. We use an custom security protocol due which we don't respond any WWW-Authenticate header. I will see if i add a fake one as workaround. Or if i changed it to the 403 status code. – Spons Aug 18 '14 at 13:33
  • @Rudolfwm, please Add an anwser with link to the other question. Or written by you, so i can accept it. As you deserve the points ;) – Spons Aug 18 '14 at 13:34
  • glad to be of help :) – Rudolfwm Aug 18 '14 at 15:02

1 Answers1

0
 Example errors: "java.io.IOException: No authentication challenges found" or "java.io.IOException: Received authentication challenge is null"

Apparently, your server is using authentication somewhere. See for explanation and solutions in this answer.

Community
  • 1
  • 1
Rudolfwm
  • 689
  • 6
  • 15