Afnetworking响应500 - 响应成功第二次呼叫 - 邮差 - 一直都好

时间:2014-02-27 14:27:36

标签: ios iphone afnetworking

我开发了一个应用程序,我使用AFNetworking与服务器通信。除了一个返回状态代码:500 的调用之外,其他任何东西都是如此。我第二次打电话给WS是好的。

我的方法:

-(IBAction)quizzSubmit:(id)sender {

        BusinessLogic *bl = [BusinessLogic sharedManager];

        [AlertDFF alertWithTitle:@"Loading ..." owner:self];

        NSString *plm = [NSString stringWithFormat:@"[{\"nid\":%d,\"score\":%d,\"time\":%d,\"options\":{\"cid1\":\"%@\",\"cid2\":\"%@\",\"cid3\":\"%@\",\"cid4\":\"%@\",\"cid5\":\"%@\",\"cid6\":\"%@\",\"cid7\":\"%@\",\"cid8\":\"%@\",\"cid9\":\"%@\",\"cid10\":\"%@\"}}]", self.quizzId, self.score, self.time, [self.quizzAnswersDic objectForKey:@"cid1"], [self.quizzAnswersDic objectForKey:@"cid2"], [self.quizzAnswersDic objectForKey:@"cid3"], [self.quizzAnswersDic objectForKey:@"cid4"], [self.quizzAnswersDic objectForKey:@"cid5"], [self.quizzAnswersDic objectForKey:@"cid6"], [self.quizzAnswersDic objectForKey:@"cid7"], [self.quizzAnswersDic objectForKey:@"cid8"], [self.quizzAnswersDic objectForKey:@"cid9"], [self.quizzAnswersDic objectForKey:@"cid10"]];

        NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                                bl.currentUser.hash, @"hash",
                                plm,@"quizzes",
                                nil];

        ApiClientBlitzApp *client = [ApiClientBlitzApp sharedClient];
        NSURLRequest *request = [client requestWithMethod:@"POST" path:getQuizSubmit parameters:params];

        AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest
*request, NSHTTPURLResponse *response, id resultObjectsJSON) 
        {
                  if (resultObjectsJSON count]>0){
                        [AlertDFF dismissAlertInController:self];
                        [Utils showAlert:@“Your Quiz Result was sent ! ” andDelegate:nil];
                  }else{
                        [AlertDFF dismissAlertInController:self];
                        [Utils showAlert:@“Problems ! Please try again later! ” andDelegate:nil];
                 }  

        }failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
            NSLog(@"ERROR response = %@ /n", response);
            NSLog(@"error     = %@", error);
            [AlertDFF dismissAlertInController:self];
        }];
        [operation start];
    } }



  The WS team told me that my request doesn't reah to the server.
  If I press second time the button and call again the metod everthing it's oky.
  I need some help with this problem please.

  I test the request on Chrome - Postman and everything it's oky. 

enter image description here enter image description here

0 个答案:

没有答案