trouble with payload in iOS SDK








  • I'm new to the api but stuck with the payload object passed in with requestWithMethod:path:payload from LQSession.

    I'm creating an NSDictionary and using it as my payload but its not recognizing the key pair with the error:  Layer name is required.  name is in my NSDictionary, so not sure what I'm missingI've tried other api calls with the same results.  Any suggestions would be greatly appreciated!


    Here is my code:

       NSDictionary *layer = [[NSDictionary alloc] initWithObjectsAndKeys: @"sample layer name", @"name", @"1", @"public"nil];


                NSLog(@"%@", layer);


                NSURLRequest *r = [session requestWithMethod:@"GET" path:@"/layer/create" payload:layer];


                [session runAPIRequest:r completion:^(NSHTTPURLResponse *response, NSDictionary *responseDictionary, NSError *error) {


                    NSLog(@"Response: %@ error:%@", responseDictionary, error);


                }];



    Here is the log:









    2012-06-09 22:30:05.649 Test[13810:11903] {


        public = 1;


        name = sample layer name;


    }


    /__38-[LQSession runAPIRequest:completion:]_block_invoke_0 (LQSession.m:390) API Request: https://api.geoloqi.com/1/layer/create


    /__38-[LQSession runAPIRequest:completion:]_block_invoke_0 (LQSession.m:401) Error: Error Domain=api.geoloqi.com Code=400 "Layer name is required" UserInfo=XXXXXX {NSUnderlyingError=0x83b5890 "The operation couldn’t be completed. (api.geoloqi.com error 400.)", NSLocalizedDescription=Layer name is required}


    2012-06-09 22:30:05.751 Test[13810:11903] Response: {


        error = "missing_name";


        "error_code" = 400;


        "error_description" = "Layer name is required";


    } error:Error Domain=api.geoloqi.com Code=400 "Layer name is required" UserInfo=0x83b4790 {NSUnderlyingError=0x83b5890 "The operation couldn’t be completed. (api.geoloqi.com error 400.)", NSLocalizedDescription=Layer name is required}

  • 2 Comments sorted by
  • Looks like you need to change requestWithMethod:@"GET" to requestWithMethod:@"POST".
  • Where's the easy button!?  Many thanks Aaron - that was it.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion