So i am trying to make an http request using ASIHTTPRequest class , to send a json file to my server. I was given an android code which is functional and was asked to convert it to iOS code.
I cant understand how to add headers on my request.The android code looks something like this :
private static final String CONTENT_TYPE = "Content-Type";
private static final String JSON_CONTENT_TYPE = "application/json; charset=utf-8";
and then :
request.addHeader(CONTENT_TYPE, JSON_CONTENT_TYPE);
On iOS i figured out that the code is something like this :
[request addRequestHeader:@"Content-Type" value:@"Content-Type"];
[request addRequestHeader:@"Json-Content-Type" value:@"application/json; charset=utf-8"];
BUT i got a bit confused , cause on android the request seems to be paired and on iOS the requestHeaders are individually stated. Is this a problem? Should they be paired too on iOS. Am i missing something here? Thank you for reading my post 😀
What you want is
in the android example, they are just declaring two variables for the header values, they could had simply done something like
which would have had the same effect, so you just need the one line i mentioned above.
also:
ASIHTTPREQUESTdoes not get developed any more (see headline here), so consider using another library for something like this, like AFNetworking