Please tell me - what is wrong in the code? Sends the result: "status code 200". I need "status code 201".
NSMutableURLRequest * signUpRequest = [NSMutableURLRequest requestWithURL: [NSURL URLWithString: @ " http://staging.api.kiteflightapp.com "] cachePolicy: NSURLRequestUseProtocolCachePolicy timeoutInterval: 15.0];
NSString *api_key = [NSString stringWithFormat:@"register?api_key=&g4sksgk0kspscc4oogo8wow0w0ocossg000og0so"]; NSString *name_first = [NSString stringWithFormat:@"name_first=&john"]; NSString *name_last = [NSString stringWithFormat:@"name_last=&Logan"]; NSString *email_address = [NSString stringWithFormat:@"email_address= &test1ios@test.com"]; NSString *password = [NSString stringWithFormat:@"password=&010101"]; NSString *device_token = [NSString stringWithFormat:@"device_token= &123456"]; NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration]; NSURLSession *currentSession = [NSURLSession sessionWithConfiguration:sessionConfiguration]; [signUpRequest setHTTPMethod:@"POST"]; [signUpRequest setHTTPBody:[api_key dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]]; [signUpRequest setHTTPBody:[name_first dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]]; [signUpRequest setHTTPBody:[name_last dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]]; [signUpRequest setHTTPBody:[email_address dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]]; [signUpRequest setHTTPBody:[password dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]]; [signUpRequest setHTTPBody:[device_token dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]]; [signUpRequest setValue:@"http://staging.api.kiteflightapp.com" forHTTPHeaderField:@"Content-Type"]; if (currentSession != nil) { } NSURLSessionDataTask *dataTask2 = [currentSession dataTaskWithRequest:signUpRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { NSLog(@"Response: %@ %@\n", response, error); if (error == nil) { NSArray *jsonArray = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error]; NSLog(@"result json: %@", jsonArray); } }]; [dataTask2 resume];
login=123&password=456, so your & in the middle of the line most likely spoil something and the server cannot figure out what you are cramming to it. Well, in general, all that can be said on your issue. - Max Mikheyenko