【问题标题】:ios Unprocessable Entity while update in Quickblox在 Quickblox 中更新时 ios 无法处理的实体
【发布时间】:2015-03-31 18:54:36
【问题描述】:

我正在开发一个聊天应用程序,并添加了用于聊天的 Quickblox 框架,但是在用户更新时出现以下错误:

请求网址:https://api.quickblox.com/users/12345.json?user%5Bemail%5D=abc%40gmail.com&user%5Bfull_name%5D=abc%xyz&user%5Blogin%5D=1234567890&user%5Bpassword%5D=abcdefghij&user%5Bphone%5D=1234567890

请求方法:PUT

请求标头:{ “内容类型”=“应用程序/json”; "QB-SDK" = "iOS 2.0.12"; “QB-令牌”= b9a57f30857d7591d6766dac7345d78bc1c9f588; “QuickBlox-REST-API-版本”=“0.1.1”; } 请求参数:{ 用户 = { 电子邮件=“abc@gmail.com”; “全名”=“abc xyz”; 登录 = 1234567890; 密码 = abcdefghij; 电话 = 1234567890; }; }

请求标头:{ “内容类型”=“应用程序/json”; "QB-SDK" = "iOS 2.0.12"; “QB-令牌”= b9a57f30857d7591d6766dac7345d78bc1c9f588; “QuickBlox-REST-API-版本”=“0.1.1”; }

响应标头:{ “访问控制允许来源”=“*”; “缓存控制”=“无缓存”; 连接=“保持活动”; “内容类型”=“应用程序/json;字符集=utf-8”; 日期 =“星期日,2015 年 2 月 1 日 18:59:19 GMT”; "QB-Token-ExpirationDate" = "2015-02-01 20:57:39 UTC"; “QuickBlox-REST-API-版本”=“0.1.1”; 服务器 = "nginx/1.0.15"; 状态 = "422 无法处理的实体"; “传输编码” = 身份; "X-Rack-Cache" = "无效,通过"; “X 请求 ID” = 17331b69e1b7a38d8545629e241733c8; “X-运行时间”=“0.013145”; "X-UA 兼容" = "IE=Edge,chrome=1"; }

我使用了以下代码...

    if (firstName.length > 0 || lastName.length > 0 || email.length > 0 || mobileNo.length > 0 || country.length > 0) {

    QBUUser *user = [QBUUser user];
    AppUser *AppUser = [AppUser user];
    user.ID = AppUser.ID;
    user.login = AppUser.login;
    user.password = AppUser.password;
    user.fullName = [NSString stringWithFormat:@"%@ %@",firstName,lastName];
    user.email = email;
    user.phone = mobileNo;

    [QBRequest updateUser:user
             successBlock:^(QBResponse *response, QBUUser *user) {

        AppUser *AppUser = [AppUser user];
        AppUser.country = country;

        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Information" message:@"Profile updated successfully." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alertView show];

    } errorBlock:^(QBResponse *response) {

        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Error while updating." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alertView show];

    }];
} else {

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Information" message:@"Fields can't be empty." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alertView show];
}

【问题讨论】:

    标签: ios quickblox


    【解决方案1】:

    尝试首先通过删除(或注释掉)上述字段之一来更新用户对象,直到找到有问题的属性。您一次更新了这么多,以至于您不知道是哪一个导致了问题。

    我怀疑登录属性是来源,因为我相信它是在注册时设置和修复的,因此之后无法更新。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多