【问题标题】:HTTP Status 500 - Request processing failedHTTP 状态 500 - 请求处理失败
【发布时间】:2014-10-14 10:59:07
【问题描述】:

我试图将字符串值发布到 Sql Server.like this

NSString *post =[NSString stringWithFormat:@"?&name=%@&password=%@&pin=%@&email=%@&phone=%@&address=%@&city=%@&status=%@",
                     name, password ,pin ,email ,phone,address,city,status];
    NSLog(@"post%@",post);
    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

    NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;

    [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://202.65.154.108:8080/SaveDollar/rest/deals/add"]]];

    NSLog(@"getData%@",request);

    [request setHTTPMethod:@"POST"];

    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];

    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"];

    [request setHTTPBody:postData];

    NSLog(@"getData%@",request);


    con3 = [[NSURLConnection alloc]initWithRequest:request delegate:self];

    if(con3)
    {      webData3=[NSMutableData data];
        NSLog(@"Connection successful");
        NSLog(@"GOOD Day My data %@",webData3);
    }
    else
    {
        NSLog(@"connection could not be made");
    }

我试过这样连接成功。

- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
NSString *responseText = [[NSString alloc] initWithData:webData3 encoding: NSASCIIStringEncoding];
        NSLog(@"Response: %@", responseText);}

但是得到这样的响应 HTTP Status 500 - Request processing failed;嵌套异常是 java.lang.NullPointerException

我不明白我的错误是什么所以请给我任何想法,并请告诉我我的代码有什么问题。

感谢高级。

【问题讨论】:

    标签: ios objective-c json post


    【解决方案1】:

    5xx 服务器错误

    HTTP 500 内部服务器错误

    一般错误消息,当遇到意外情况并且没有更具体的消息适合时给出。这个Wikipedia : - List of HTTP status codesw3.org Status codes的来源

    所以需要在服务器端检查。这不是你的问题。

    【讨论】:

    • 我还收到“服务器遇到内部错误,导致无法完成此请求。”这个错误,检查过所有的周长都和android一样吗?
    【解决方案2】:

    HTTP 500 内部错误(或)内部服务器错误

    这意味着错误可能有几个原因 - 故障可能来自服务器端,即 Json - 故障可能来自您这边,您发送的参数可能是服务器所期望的正确格式 - 错误可能是导致崩溃的编码端

    【讨论】:

      猜你喜欢
      • 2015-08-28
      • 2015-12-04
      • 2017-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多