alex da franca
alex da franca

Reputation: 1460

Setting Restkit to use text/plain for requests

In order to successfully POST using Restkit in my iOS app, the backend server setup requires me to set the requestSerializationMIMEType to @"text/plain".

[RKMIMETypeSerialization registerClass:[RKNSJSONSerialization class] forMIMEType:@"text/plain"];
sharedManager.requestSerializationMIMEType = @"text/plain";

Otherwise the server will just not respond at all and I get a "Server timed out" error after 60 seconds.

I am not sure, whether the better solution would be to change the backend server setup, as it doesn't seem to be very common that it only works with @"text/plain", when there is not even a constant for @"text/plain" defined in the Restkit/AFNetworking Frameworks.

Is that the right way to setup Restkit to use @"text/plain" as Content-Type for the (POST) requests?

Is there any downside or problems to expect later in the project?

Why do I not find that problem more often, when searching the internet? Is it such a wrong/uncommon server setup, that the backend server just doesn't respond, if the mime type is anything else but text/plain?

Upvotes: 0

Views: 190

Answers (1)

Wain
Wain

Reputation: 119041

Ok, the code you have will work, it just isn't common / logical.

Yes, you should have the server changed because it is wrong, both for requiring a plain text mime type and for not raising an error when a suitable mime type is not provided.

Future downsides:

  1. Understanding the code when you have forgotten what it does / someone new looks at it
  2. The back end is changed / upgraded by someone who knows what they're doing and then things break

Upvotes: 1

Related Questions