iOS Develoment: Why is my NSURLConnection failing with a “bad URL” error for only some users?

后端 未结 4 1236
花落未央
花落未央 2020-12-09 05:42

I have an iOS app that requests JSON data from my Rails 3 app, hosted on Heroku, and it works great on my device and for many other users, except one. I have o

相关标签:
4条回答
  • 2020-12-09 06:25

    I'm not sure how if at all it relates to your issue, but changing the Region in the Settings App had an affect on my app's ability to download. It was spitting out the same Bad URL error if the region was not set to United States. It might explain why some users are getting errors and not others.

    0 讨论(0)
  • 2020-12-09 06:31

    It doesn't look like you are encoding the username. Are there spaces or other special characters in the username? Look into using the NSString method stringByAddingPercentEscapesUsingEncoding:.

    0 讨论(0)
  • 2020-12-09 06:40

    It is likely that this depends on the specific URL containing characters that are not allowed for a URL.

    You can try and escape the URL:

    - (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding` 
    
    0 讨论(0)
  • 2020-12-09 06:45

    This kind of issue may will come due to argument data having special characters(ie. Andy & Co). SOAP automatically will reject this request and returns Bad URL or Bad Request. So, before you sending the data please ensure the data having special characters like &,<,>... If you found & in your string data , replace with <&>amp; to that string(eg.Andy <&>amp; Co). Hope this input will help for you.

    Note: Before you use,Please remove start(<>) and end tag with that symbol.

    0 讨论(0)
提交回复
热议问题