Search code examples
objective-cafnetworkingprotocol-buffers

How to analysis protobuf with AFNetworking


We use protobuf to transmit data, and I try to send a network request using AFNetworking. I can request success, but I can't resolve the datagram error

com.alamofire.serialization.response.error.data=<0a060a04 68747470 1a050a03 303030>, NSLocalizedDescription=Request failed: unacceptable content-type: application/x-protobuf}


Solution

  • AFNetworking's AFURLResponseSerializer will not allow any content type not present in its acceptableContentTypes set. In order to be able to process this data, you should provide your own response serializer and set it as your AFURLSessionManager's responseSerializer property.