11

I need send some data in http header each time when I do request to server (whith get and post methods). I am using RKObjectManager from restkit. Also I need check status returned by server (401, 200, 404 e.t.c). Does anybody know the solution?

Thanks!

Radislav
  • 2,892
  • 7
  • 38
  • 61

2 Answers2

17

in version 0.20.0rc1 you can use the following code:

[[[RKObjectManager sharedManager] HTTPClient] setDefaultHeader:myHeaderName value:myValue];
Dmitry Khryukin
  • 6,408
  • 7
  • 36
  • 58
16

If you need to send custom headers with your requests, i'd suggest to use the RKClient property HTTPHeaders, for example:

[[[[RKObjectManager sharedManager] client] HTTPHeaders] setValue:myValue
                                                          forKey:myHeaderName];

For the status code, see my another answer.

Community
  • 1
  • 1
mja
  • 5,056
  • 1
  • 29
  • 40
  • 3
    More succinctly: `[[RKObjectManager sharedManager].client setValue:myValue forHTTPHeaderField:myHeaderName];` – zaph Jul 11 '12 at 15:13
  • Does this set the header for all requests or only for one? I'm looking for a way to set a header for only a single request. (nvr mind: http://stackoverflow.com/questions/21115565/custom-headers-per-request-in-restkit) – SuperDuperTango Oct 14 '14 at 20:17