App Store receipt and base 64 encoding and AFNetworking

741 views Asked by At

Today I was really overwhelmed by an issue. I was trying to send a subscription receipt to a server to make a receipt validation with Apple servers. The web service requires to send some parameters included the receipt encode into base64 string in a POST body.
After a lot of trials we've found the problem, it seems that the encoded receipt in base 64 contains characters that are encoded again by the HTTP request serializer in URL encoding.
For what I understood the behavior of the the web service was just to pack my receipt in a JSON with a password and send it to the Apple server.
The only answer we were able to receive from Apple was 21002 status.
I've read a lot of questions on stack (here, here, here about that issue and one gave me solution, on server side just replace " " with "+".
Now it works, but I'm not feeling comfortable using that, is there a way to say AFnetworking to do not url encode some parameters? Or to rencoding in the right way?

1

There are 1 answers

0
Kevin Delord On

with AFNetworking 2.5.4 I managed to send the receipt correctly by setting the content-type of the request serializer.

var manager = AFHTTPRequestOperationManager()
manager.requestSerializer = AFHTTPRequestSerializer()
manager.requestSerializer.setValue("application/json", forHTTPHeaderField: "Content-Type")