AFNetworking and Network Errors

2019-04-15 01:42发布

I am using the AFNetworking framework to make several JSON web request.

During development if I fail to provide a required parameters or the Service developers have broken something :-) i receive a 500 error

The Error block of AFJSONRequestOperation is correctly catching it. However i cannot see the page body because AfNetworking is cancelling the request as soon as the error code in the head is received.

Is there some work around. I would like to spit out the response body to the log.

2条回答
Root(大扎)
2楼-- · 2019-04-15 02:13

Use the responseData or responseString property from the operation that's passed into the failure block.

查看更多
Emotional °昔
3楼-- · 2019-04-15 02:32

You'll need to add the http Code 500 to the acceptable status codes and filter it on the success callback. There you will have a responseObject.

查看更多
登录 后发表回答