1

I'm trying to access a server that my friend made using php. I'm using a WWW object to GET or POST json. The server always requires http basic authorization. For example, one of my GET requests to get a user's info looks like this.

https://basicauthuser:basicauthpass@x.y.com/user/samantha/

In the unity editor (v5.4.0f4), it works great! No problem. On iOS, I get a "Not Found" response (it doesn't say 404, just "Not Found"), and on Android I get a "401: Unauthorized" response.

On iOS, I've made sure that arbitrary http loads are enabled in xcode when building, but this is an HTTPS address, so it shouldn't matter. I've also tried accessing the server with an HTTP address, and I don't get any difference in response for either device.

With the WWW object, I'm sending the following headers, in case it helps:

headers.Add ("Content-Length", _jsonDataToSend.Length.ToString());
headers.Add ("Content-Type", "application/json"); 
headers.Add ("Accepts", "application/json");

Why are my calls failing on iOS and Android?

halfer
  • 19,824
  • 17
  • 99
  • 186
Catlard
  • 853
  • 6
  • 13
  • 30

1 Answers1

1

Maybe the access problem:

Unity requires that websites you want to access via a WWW Request have a cross domain policy.

<?xml version="1.0"?>
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>

Upload this file to the root of your web server(ref).

Muhammad Faizan Khan
  • 10,013
  • 18
  • 97
  • 186