makeWebRequest in Simulator returns -1001 instead of 401

Former Member
Former Member
When I make request through makeWebRequest(), which I expect to return 401 (NotAuthorized), I get the -1001 result instead. Why is this happening? Protocol is http (not https).

P.S. I don't know what happens on read device (not simulator) in this case, because I only tested on simulator.
  • Look at the API Doc in the SDK. a -1001 is "SECURE_CONNECTION_REQUIRED". You see that if you try HTTP instead of HTTPS. In the sim, under settings, there is a box you can uncheck for "Use Device HTTPS Requirements" which will allow HTTP, but you'll want to use HTTPS on the device.

    See This post and "Changes to makeWebRequest" from the developer blog.
  • Former Member
    Former Member over 6 years ago
    jim_m_58 hm, thank you, it worked! I cannot switch to https, I would if I could, but the server is not accepting https.

    Also, with some headers being null, I get a -200 error (INVALID_HTTP_HEADER_FIELDS_IN_REQUEST). Any ideas what this might mean? I cannot include headers with null value? Empty string works, on the other hand.
  • I saw you posted in the bug report forum - I myself haven't seen a -200 in that case (I never needed a null). As far as HTTP vs HTTPS, that may mean you won't because to use an iPhone, and I'd have to try on Android to know for that. I switched everything to https in my apps some time ago.
  • I don't know if this is feasible for you (as far as bandwidth/hosting costs go), but it sounds like the best solution in this case would be to write a proxy for the HTTP service.

    I'm guessing that you should be able to stay within the free limits for a service like appspot.com, though.
  • Former Member
    Former Member over 6 years ago
    Yep, thank you, folks! At least now I know what's going on, and can mitigate these problems, implement workarounds.