Getting back HTTP error 406 when trying to post data.

282 views
Skip to first unread message

Keisi

unread,
Jan 16, 2012, 2:04:10 PM1/16/12
to res...@googlegroups.com
I am trying to set up RKClient post request for the following cURL statement

curl -i -H "Content-Type: application/json" -H "Accept: application/json" -d '{"username":"username","password":"password"}' url_goes_here

which returns the expected json.

However, when I set up RestKit as follows i get an HTTP 406 error code, I cannot understand what is happening.

Note: url_goes_here is equivalent to the final url after RKClient merges it with the base_url.

[[RKClient sharedClient] setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[[RKClient sharedClient] setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:@"admin",@"username",@"password",@"password", nil];
[[RKClient sharedClient] post:@"/login" params:params delegate:self];

The error I am getting is as follows

2012-01-16 14:01:22.210 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:319 Request <RKRequest: 0x6ba1200> added to queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=0 loadingCount=0/5>
2012-01-16 14:01:22.211 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:265 Processing request <RKRequest: 0x6ba1200> in queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=0/5>
2012-01-16 14:01:22.212 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:189 Loading count increasing from 0 to 1. Firing requestQueueDidBeginLoading
2012-01-16 14:01:22.213 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:216 Loading count set to 1 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=0/5>
2012-01-16 14:01:22.215 App Name[3586:fb03] T restkit.network.cache:RKRequestCache.m:122 Found cachePath '/Users/USERNAME/Library/Application Support/iPhone Simulator/5.0/Applications/2E5D0404-C6E7-4473-BA2B-96706E5EABA4/Library/Caches/RKClientRequestCache-www.examplec.om/PermanentStore/1f23df72223f9eff6ef2d495fd92b44b' for <RKRequest: 0x6ba1200>
2012-01-16 14:01:22.216 App Name[3586:fb03] T restkit.network.cache:RKRequestCache.m:143 Determined hasResponseForRequest: <RKRequest: 0x6ba1200> => YES
2012-01-16 14:01:22.217 App Name[3586:fb03] T restkit.network.cache:RKRequestCache.m:122 Found cachePath '/Users/USERNAME/Library/Application Support/iPhone Simulator/5.0/Applications/2E5D0404-C6E7-4473-BA2B-96706E5EABA4/Library/Caches/RKClientRequestCache-www.examplec.om/PermanentStore/1f23df72223f9eff6ef2d495fd92b44b' for <RKRequest: 0x6ba1200>
2012-01-16 14:01:22.218 App Name[3586:fb03] D restkit.network.cache:RKRequestCache.m:248 Read cached headers '{
    "Cache-Control" = "store, no-cache, must-revalidate, post-check=0, pre-check=0";
    Connection = close;
    "Content-Length" = 98;
    "Content-Type" = "text/yaml";
    Date = "Sun, 15 Jan 2012 20:19:02 GMT";
    Expires = "Sun, 19 Nov 1978 05:00:00 GMT";
    "Last-Modified" = "Sun, 15 Jan 2012 20:19:02 GMT";
    Server = Apache;
    "Set-Cookie" = "SESS392dc6c3f829905de7d630dcfc5b01cb=deleted; expires=Sat, 15-Jan-2011 20:19:01 GMT; path=/, SESS392dc6c3f829905de7d630dcfc5b01cb=mm7k534snoipddaduv6828dld5; expires=Tue, 07-Feb-2012 23:52:22 GMT; path=/; domain=.www.examplec.om, SESS392dc6c3f829905de7d630dcfc5b01cb=deleted; expires=Sat, 15-Jan-2011 20:19:01 GMT; path=/, SESS392dc6c3f829905de7d630dcfc5b01cb=bmgn3pi1lijrrespjiadm77tj3; expires=Tue, 07-Feb-2012 23:52:22 GMT; path=/; domain=.www.examplec.om";
    Vary = Accept;
    "X-RESTKIT-CACHED-MIME-TYPE" = "text/yaml";
    "X-RESTKIT-CACHED-RESPONSE-CODE" = 200;
    "X-RESTKIT-CACHED-URL" = "http://www.examplec.om/pms/user/login";
    "X-RESTKIT-CACHEDATE" = "Sun, 15 Jan 2012 20:19:03 GMT";
}' from cachePath '/Users/USERNAME/Library/Application Support/iPhone Simulator/5.0/Applications/2E5D0404-C6E7-4473-BA2B-96706E5EABA4/Library/Caches/RKClientRequestCache-www.examplec.om/PermanentStore/1f23df72223f9eff6ef2d495fd92b44b.headers' for '<RKRequest: 0x6ba1200>'
2012-01-16 14:01:22.219 App Name[3586:fb03] D restkit.network.cache:RKRequestCache.m:315 Found cached date '2012-01-15 20:19:03 +0000' for '<RKRequest: 0x6ba1200>'
2012-01-16 14:01:22.220 App Name[3586:fb03] T restkit.network.reachability:RKReachabilityObserver.m:240 Reachability Flags: -R -----l-
2012-01-16 14:01:22.220 App Name[3586:fb03] T restkit.network.reachability:RKReachabilityObserver.m:283 Reachability observer <RKReachabilityObserver: 0x839e870 host=0.0.0.0 isReachabilityDetermined=YES isMonitoringLocalWiFi=723800 reachabilityFlags=-R -----l-> determined networkStatus = RKReachabilityReachableViaWiFi
2012-01-16 14:01:22.221 App Name[3586:fb03] D restkit.network.reachability:RKReachabilityObserver.m:297 Reachability observer <RKReachabilityObserver: 0x839e870 host=0.0.0.0 isReachabilityDetermined=YES isMonitoringLocalWiFi=723800 reachabilityFlags=-R -----l-> determined isNetworkReachable = 1
2012-01-16 14:01:22.222 App Name[3586:fb03] D restkit.network:RKRequest.m:365 Sending asynchronous POST request to URL http://www.examplec.om/pms/user/login.
2012-01-16 14:01:22.223 App Name[3586:fb03] T restkit.network.cache:RKRequestCache.m:122 Found cachePath '/Users/USERNAME/Library/Application Support/iPhone Simulator/5.0/Applications/2E5D0404-C6E7-4473-BA2B-96706E5EABA4/Library/Caches/RKClientRequestCache-www.examplec.om/PermanentStore/1f23df72223f9eff6ef2d495fd92b44b' for <RKRequest: 0x6ba1200>
2012-01-16 14:01:22.224 App Name[3586:fb03] D restkit.network.cache:RKRequestCache.m:248 Read cached headers '{
    "Cache-Control" = "store, no-cache, must-revalidate, post-check=0, pre-check=0";
    Connection = close;
    "Content-Length" = 98;
    "Content-Type" = "text/yaml";
    Date = "Sun, 15 Jan 2012 20:19:02 GMT";
    Expires = "Sun, 19 Nov 1978 05:00:00 GMT";
    "Last-Modified" = "Sun, 15 Jan 2012 20:19:02 GMT";
    Server = Apache;
    "Set-Cookie" = "SESS392dc6c3f829905de7d630dcfc5b01cb=deleted; expires=Sat, 15-Jan-2011 20:19:01 GMT; path=/, SESS392dc6c3f829905de7d630dcfc5b01cb=mm7k534snoipddaduv6828dld5; expires=Tue, 07-Feb-2012 23:52:22 GMT; path=/; domain=.www.examplec.om, SESS392dc6c3f829905de7d630dcfc5b01cb=deleted; expires=Sat, 15-Jan-2011 20:19:01 GMT; path=/, SESS392dc6c3f829905de7d630dcfc5b01cb=bmgn3pi1lijrrespjiadm77tj3; expires=Tue, 07-Feb-2012 23:52:22 GMT; path=/; domain=.www.examplec.om";
    Vary = Accept;
    "X-RESTKIT-CACHED-MIME-TYPE" = "text/yaml";
    "X-RESTKIT-CACHED-RESPONSE-CODE" = 200;
    "X-RESTKIT-CACHED-URL" = "http://www.examplec.om/pms/user/login";
    "X-RESTKIT-CACHEDATE" = "Sun, 15 Jan 2012 20:19:03 GMT";
}' from cachePath '/Users/USERNAME/Library/Application Support/iPhone Simulator/5.0/Applications/2E5D0404-C6E7-4473-BA2B-96706E5EABA4/Library/Caches/RKClientRequestCache-www.examplec.om/PermanentStore/1f23df72223f9eff6ef2d495fd92b44b.headers' for '<RKRequest: 0x6ba1200>'
2012-01-16 14:01:22.225 App Name[3586:fb03] D restkit.network.cache:RKRequestCache.m:278 Found cached ETag '(null)' for '<RKRequest: 0x6ba1200>'
2012-01-16 14:01:22.225 App Name[3586:fb03] T restkit.network:RKRequest.m:313 Prepared POST URLRequest '<NSMutableURLRequest http://www.examplec.om/pms/user/login>'. HTTP Headers: {
    Accept = "application/json";
    "Content-Type" = "application/x-www-form-urlencoded";
}. HTTP Body: username=admin&password=jurassic.
2012-01-16 14:01:22.226 App Name[3586:fb03] D restkit.network.queue:RKRequestQueue.m:272 Sent request <RKRequest: 0x6ba1200> from queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>. Loading count = 1 of 5
2012-01-16 14:01:22.227 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:22.528 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:22.829 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:23.130 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:23.431 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:23.732 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:24.034 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:24.334 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:24.635 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:24.936 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:25.237 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:25.537 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:25.666 App Name[3586:fb03] D restkit.network:RKResponse.m:189 NSHTTPURLResponse Status Code: 406
2012-01-16 14:01:25.667 App Name[3586:fb03] D restkit.network:RKResponse.m:190 Headers: {
    "Cache-Control" = "store, no-cache, must-revalidate, post-check=0, pre-check=0";
    Connection = close;
    "Content-Length" = 4;
    "Content-Type" = "application/json";
    Date = "Mon, 16 Jan 2012 19:01:25 GMT";
    Expires = "Sun, 19 Nov 1978 05:00:00 GMT";
    "Last-Modified" = "Mon, 16 Jan 2012 19:01:25 GMT";
    Server = Apache;
    Vary = Accept;
}
2012-01-16 14:01:25.667 App Name[3586:fb03] T restkit.network:RKResponse.m:195 Read response body: null
2012-01-16 14:01:25.668 App Name[3586:fb03] I restkit.network:RKRequest.m:565 Status Code: 406
2012-01-16 14:01:25.668 App Name[3586:fb03] D restkit.network:RKRequest.m:566 Body: null
Current language:  auto; currently objective-c
2012-01-16 14:01:38.365 App Name[3586:fb03] Response body <6e756c6c>
2012-01-16 14:01:41.477 App Name[3586:fb03] contentType application/json
2012-01-16 14:01:43.900 App Name[3586:fb03] Got a JSON response back from our POST!
2012-01-16 14:01:46.289 App Name[3586:fb03] parsed null
2012-01-16 14:01:49.174 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:340 Removing request <RKRequest: 0x6ba1200> from queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
2012-01-16 14:01:49.175 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:202 Loading count decreasing from 1 to 0. Firing requestQueueDidFinishLoading
2012-01-16 14:01:49.176 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:216 Loading count set to 0 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=0 loadingCount=1/5>
2012-01-16 14:01:49.177 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:352 Decremented the loading count to 0
2012-01-16 14:01:49.178 App Name[3586:fb03] D restkit.network.queue:RKRequestQueue.m:443 Received response for request <RKRequest: 0x6ba1200>, removing from queue. (Now loading 0 of 5)


Any help would be appreciated

Shane Zatezalo

unread,
Jan 16, 2012, 2:32:40 PM1/16/12
to res...@googlegroups.com
Isn't curl -d posting that information into the body of the message? You are telling Restkit to send the information via params:params.

Keisi

unread,
Jan 16, 2012, 3:26:56 PM1/16/12
to RestKit
Yes it does, I tried to update my code to the following but I am
getting the same response.

RKRequest *request = [RKRequest requestWithURL:URL delegate:self];
request.queue = [RKClient sharedClient].requestQueue;
request.method = RKRequestMethodPOST;
request.HTTPBodyString = @"{\"username\":\"username\",\"password\":
\"password\"}";
request.additionalHTTPHeaders = [NSDictionary
dictionaryWithObjectsAndKeys:@"application/
json",@"Accept",@"application/json",@"Content-type",@"42",@"Content-
length", nil];
[request send];

On Jan 16, 2:32 pm, Shane Zatezalo <lotta...@gmail.com> wrote:
> Isn't curl -d posting that information into the body of the message? You are telling Restkit to send the information via params:params.
>
> On Jan 16, 2012, at 2:04 PM, Keisi wrote:
>
>
>
>
>
>
>
> > I am trying to set up RKClient post request for the following cURL statement
>
> > curl -i -H "Content-Type: application/json" -H "Accept: application/json" -d '{"username":"username","password":"password"}' url_goes_here
>
> > which returns the expected json.
>
> > However, when I set up RestKit as follows i get an HTTP 406 error code, I cannot understand what is happening.
>
> > Note: url_goes_here is equivalent to the final url after RKClient merges it with the base_url.
>
> > [[RKClient sharedClient] setValue:@"application/json" forHTTPHeaderField:@"Accept"];
> > [[RKClient sharedClient] setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
>
> > NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:@"admin",@"username",@"password",@"password", nil];
> > [[RKClient sharedClient] post:@"/login" params:params delegate:self];
>
> > The error I am getting is as follows
>
> > 2012-01-16 14:01:22.210 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:319 Request <RKRequest: 0x6ba1200> added to queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=0 loadingCount=0/5>
> > 2012-01-16 14:01:22.211 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:265 Processing request <RKRequest: 0x6ba1200> in queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=0/5>
> > 2012-01-16 14:01:22.212 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:189 Loading count increasing from 0 to 1. Firing requestQueueDidBeginLoading
> > 2012-01-16 14:01:22.213 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:216 Loading count set to 1 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=0/5>
> > 2012-01-16 14:01:22.215 App Name[3586:fb03] T restkit.network.cache:RKRequestCache.m:122 Found cachePath '/Users/USERNAME/Library/Application Support/iPhone Simulator/5.0/Applications/2E5D0404-C6E7-4473-BA2B-96706E5EABA4/Library/Cac hes/RKClientRequestCache-www.examplec.om/PermanentStore/1f23df72223f9eff6ef2d495fd92b44b'for <RKRequest: 0x6ba1200>
> > 2012-01-16 14:01:22.216 App Name[3586:fb03] T restkit.network.cache:RKRequestCache.m:143 Determined hasResponseForRequest: <RKRequest: 0x6ba1200> => YES
> > 2012-01-16 14:01:22.217 App Name[3586:fb03] T restkit.network.cache:RKRequestCache.m:122 Found cachePath '/Users/USERNAME/Library/Application Support/iPhone Simulator/5.0/Applications/2E5D0404-C6E7-4473-BA2B-96706E5EABA4/Library/Cac hes/RKClientRequestCache-www.examplec.om/PermanentStore/1f23df72223f9eff6ef2d495fd92b44b'for <RKRequest: 0x6ba1200>
> > 2012-01-16 14:01:22.218 App Name[3586:fb03] D restkit.network.cache:RKRequestCache.m:248 Read cached headers '{
> >     "Cache-Control" = "store, no-cache, must-revalidate, post-check=0, pre-check=0";
> >     Connection = close;
> >     "Content-Length" = 98;
> >     "Content-Type" = "text/yaml";
> >     Date = "Sun, 15 Jan 2012 20:19:02 GMT";
> >     Expires = "Sun, 19 Nov 1978 05:00:00 GMT";
> >     "Last-Modified" = "Sun, 15 Jan 2012 20:19:02 GMT";
> >     Server = Apache;
> >     "Set-Cookie" = "SESS392dc6c3f829905de7d630dcfc5b01cb=deleted; expires=Sat, 15-Jan-2011 20:19:01 GMT; path=/, SESS392dc6c3f829905de7d630dcfc5b01cb=mm7k534snoipddaduv6828dld5; expires=Tue, 07-Feb-2012 23:52:22 GMT; path=/; domain=.www.examplec.om, SESS392dc6c3f829905de7d630dcfc5b01cb=deleted; expires=Sat, 15-Jan-2011 20:19:01 GMT; path=/, SESS392dc6c3f829905de7d630dcfc5b01cb=bmgn3pi1lijrrespjiadm77tj3; expires=Tue, 07-Feb-2012 23:52:22 GMT; path=/; domain=.www.examplec.om";
> >     Vary = Accept;
> >     "X-RESTKIT-CACHED-MIME-TYPE" = "text/yaml";
> >     "X-RESTKIT-CACHED-RESPONSE-CODE" = 200;
> >     "X-RESTKIT-CACHED-URL" = "http://www.examplec.om/pms/user/login";
> >     "X-RESTKIT-CACHEDATE" = "Sun, 15 Jan 2012 20:19:03 GMT";
> > }' from cachePath '/Users/USERNAME/Library/Application Support/iPhone Simulator/5.0/Applications/2E5D0404-C6E7-4473-BA2B-96706E5EABA4/Library/Cac hes/RKClientRequestCache-www.examplec.om/PermanentStore/1f23df72223f9eff6ef2d495fd92b44b.headers'for '<RKRequest: 0x6ba1200>'
> > 2012-01-16 14:01:22.219 App Name[3586:fb03] D restkit.network.cache:RKRequestCache.m:315 Found cached date '2012-01-15 20:19:03 +0000' for '<RKRequest: 0x6ba1200>'
> > 2012-01-16 14:01:22.220 App Name[3586:fb03] T restkit.network.reachability:RKReachabilityObserver.m:240 Reachability Flags: -R -----l-
> > 2012-01-16 14:01:22.220 App Name[3586:fb03] T restkit.network.reachability:RKReachabilityObserver.m:283 Reachability observer <RKReachabilityObserver: 0x839e870 host=0.0.0.0 isReachabilityDetermined=YES isMonitoringLocalWiFi=723800 reachabilityFlags=-R -----l-> determined networkStatus = RKReachabilityReachableViaWiFi
> > 2012-01-16 14:01:22.221 App Name[3586:fb03] D restkit.network.reachability:RKReachabilityObserver.m:297 Reachability observer <RKReachabilityObserver: 0x839e870 host=0.0.0.0 isReachabilityDetermined=YES isMonitoringLocalWiFi=723800 reachabilityFlags=-R -----l-> determined isNetworkReachable = 1
> > 2012-01-16 14:01:22.222 App Name[3586:fb03] D restkit.network:RKRequest.m:365 Sending asynchronous POST request to URLhttp://www.examplec.om/pms/user/login.
> > 2012-01-16 14:01:22.223 App Name[3586:fb03] T restkit.network.cache:RKRequestCache.m:122 Found cachePath '/Users/USERNAME/Library/Application Support/iPhone Simulator/5.0/Applications/2E5D0404-C6E7-4473-BA2B-96706E5EABA4/Library/Cac hes/RKClientRequestCache-www.examplec.om/PermanentStore/1f23df72223f9eff6ef2d495fd92b44b'for <RKRequest: 0x6ba1200>
> > 2012-01-16 14:01:22.224 App Name[3586:fb03] D restkit.network.cache:RKRequestCache.m:248 Read cached headers '{
> >     "Cache-Control" = "store, no-cache, must-revalidate, post-check=0, pre-check=0";
> >     Connection = close;
> >     "Content-Length" = 98;
> >     "Content-Type" = "text/yaml";
> >     Date = "Sun, 15 Jan 2012 20:19:02 GMT";
> >     Expires = "Sun, 19 Nov 1978 05:00:00 GMT";
> >     "Last-Modified" = "Sun, 15 Jan 2012 20:19:02 GMT";
> >     Server = Apache;
> >     "Set-Cookie" = "SESS392dc6c3f829905de7d630dcfc5b01cb=deleted; expires=Sat, 15-Jan-2011 20:19:01 GMT; path=/, SESS392dc6c3f829905de7d630dcfc5b01cb=mm7k534snoipddaduv6828dld5; expires=Tue, 07-Feb-2012 23:52:22 GMT; path=/; domain=.www.examplec.om, SESS392dc6c3f829905de7d630dcfc5b01cb=deleted; expires=Sat, 15-Jan-2011 20:19:01 GMT; path=/, SESS392dc6c3f829905de7d630dcfc5b01cb=bmgn3pi1lijrrespjiadm77tj3; expires=Tue, 07-Feb-2012 23:52:22 GMT; path=/; domain=.www.examplec.om";
> >     Vary = Accept;
> >     "X-RESTKIT-CACHED-MIME-TYPE" = "text/yaml";
> >     "X-RESTKIT-CACHED-RESPONSE-CODE" = 200;
> >     "X-RESTKIT-CACHED-URL" = "http://www.examplec.om/pms/user/login";
> >     "X-RESTKIT-CACHEDATE" = "Sun, 15 Jan 2012 20:19:03 GMT";
> > }' from cachePath '/Users/USERNAME/Library/Application Support/iPhone Simulator/5.0/Applications/2E5D0404-C6E7-4473-BA2B-96706E5EABA4/Library/Cac hes/RKClientRequestCache-www.examplec.om/PermanentStore/1f23df72223f9eff6ef2d495fd92b44b.headers'for '<RKRequest: 0x6ba1200>'
> > 2012-01-16 14:01:22.225 App Name[3586:fb03] D restkit.network.cache:RKRequestCache.m:278 Found cached ETag '(null)' for '<RKRequest: 0x6ba1200>'
> > 2012-01-16 14:01:22.225 App Name[3586:fb03] T restkit.network:RKRequest.m:313 Prepared POST URLRequest '<NSMutableURLRequesthttp://www.examplec.om/pms/user/login>'. HTTP Headers: {
> >     Accept = "application/json";
> >     "Content-Type" = "application/x-www-form-urlencoded";
> > }. HTTP Body: username=admin&password=jurassic.
> > 2012-01-16 14:01:22.226 App Name[3586:fb03] D restkit.network.queue:RKRequestQueue.m:272 Sent request <RKRequest: 0x6ba1200> from queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>. Loading count = 1 of 5
> > 2012-01-16 14:01:22.227 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
> > 2012-01-16 14:01:22.528 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
> > 2012-01-16 14:01:22.829 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
> > 2012-01-16 14:01:23.130 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
> > 2012-01-16 14:01:23.431 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
> > 2012-01-16 14:01:23.732 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
> > 2012-01-16 14:01:24.034 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
> > 2012-01-16 14:01:24.334 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
> > 2012-01-16 14:01:24.635 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with delay 0.300000 for queue <RKRequestQueue: 0x839ca50 name=(null) suspended=NO requestCount=1 loadingCount=1/5>
> > 2012-01-16 14:01:24.936 App Name[3586:fb03] T restkit.network.queue:RKRequestQueue.m:227 Timer initialized with...
>
> read more »

Keisi

unread,
Jan 16, 2012, 3:27:24 PM1/16/12
to RestKit
As a note, I tried to use NSURLConnections and the same thing was
happening????

Now I am pretty lost.

Jonathan Hoskin

unread,
Jan 16, 2012, 3:54:52 PM1/16/12
to res...@googlegroups.com


I think I've made this recommendation before on this list, but here goes again. It would be a really good idea to use a debugging HTTP proxy to see what is actually being sent and recieved over the wire.

I use one every day and I don't know how anyone can develop a web-connected app without it.

The one I use is Charles: http://charlesproxy.com

If you are using the iOS simulator, you don't need to do anything to make it go through Charles, it just works.

-Jonathan

Keisi

unread,
Jan 16, 2012, 4:09:34 PM1/16/12
to RestKit
Wow,

Jonathan thank you so much!!! That was incredibly useful. In
retrospect though it showed me a fatal mistake, when I tried to login
using while running Charles I got the response

***************
Response Code | 406 Not Acceptable: Already logged in as admin
***************

So, I cleared the simulator restarted and it was golden! Now, I am
just confused as to why the server was allowing me to "log in"
multiple times through cURL but not through the simulator.

As a side but-related question. Do you know how to print these
description of the error message

For example "Already logged in as admin" or "Missing required argument
username" which I did manage to get through cURL. statusCode just
returns 406 and localizedStatusCode just returned unacceptable.

Thanks for the advise to pick up Charles.

Jonathan Hoskin

unread,
Jan 16, 2012, 5:30:28 PM1/16/12
to res...@googlegroups.com

On 17/01/2012, at 10:09 AM, Keisi wrote:

> Wow,
>
> Jonathan thank you so much!!! That was incredibly useful. In
> retrospect though it showed me a fatal mistake, when I tried to login
> using while running Charles I got the response
>
> ***************
> Response Code | 406 Not Acceptable: Already logged in as admin
> ***************
>
> So, I cleared the simulator restarted and it was golden! Now, I am
> just confused as to why the server was allowing me to "log in"
> multiple times through cURL but not through the simulator.

It sounds like the server is creating a session cookie in the app on the simulator after you log in; I would imagine if you wiped the simulator again it would allow you to log in again.

In one of my apps, I do this to delete all local cookies, when I want to make sure my app is "logged out" of my server:

NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];
for (NSHTTPCookie *cookie in cookies) {
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
}

RestKit may also have some magic method for doing this.


> As a side but-related question. Do you know how to print these
> description of the error message
>
> For example "Already logged in as admin" or "Missing required argument
> username" which I did manage to get through cURL. statusCode just
> returns 406 and localizedStatusCode just returned unacceptable.

I assume you are getting called back with this method:

- (void)objectLoader:(RKObjectLoader*)objectLoader didFailWithError:(NSError*)error

In which case, you should be able to inspect objectloader.response.body to see that error message.


Reply all
Reply to author
Forward
0 new messages