Ive tried to avoid asking such a newb question on here, but im a Android dev learning IOS and I cant figure out for the life of me how to add a simple header to my post requests
Under AFHTTPRequestOperationManager
you will notice a property called requestSerializer
. This is of type AFHTTPRequestSerializer
, and requests made through the HTTP manager are constructed with the headers specified by this object.
So, try this:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager.requestSerializer setValue:@"SomeValue" forHTTPHeaderField:@"SomeHeaderField"]
//Make your requests
You can read the headers dictionary from the request serializer as follows:
manager.requestSerializer.HTTPRequestHeaders
Note that once you set a header this way, it will be used for all other operations!