I'm consuming a webservice and when something fails for validation reasons the error message is in the StatusDescription. I need a way to get that and display it to the user but all I see on NSHTTPURLResponse is the StatusCode and a way to convert the status code to the standard error message.
The web server always returns a 500 status code no matter the data error so I can't infer the problem from the code.
You can obtain a standard error message like that:
[NSHTTPURLResponse localizedStringForStatusCode:httpResponse.statusCode];
Although there is no way to get the reason message from the given response using Foundation Framework if your server provides additional message there. You should use Core Foundation classes for that. The last provides such ability:
CFStringRef myStatusLine = CFHTTPMessageCopyResponseStatusLine(myResponse);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With