我正在开发一个聊天应用程序,我已经为聊天添加了Quickblox框架,但是当用户更新时出现以下错误:
请求方法:PUT
请求标头:{ "内容类型" =" application / json&#34 ;; " QB-SDK" =" iOS 2.0.12&#34 ;; " QB-令牌" = b9a57f30857d7591d6766dac7345d78bc1c9f588; " QuickBlox-REST-API-版" =" 0.1.1&#34 ;; } 请求参数:{ user = { email =" abc@gmail.com" ;; " FULL_NAME" =" abc xyz&#34 ;; login = 1234567890; 密码= abcdefghij; 电话= 1234567890; }; }
请求标头:{ "内容类型" =" application / json&#34 ;; " QB-SDK" =" iOS 2.0.12&#34 ;; " QB-令牌" = b9a57f30857d7591d6766dac7345d78bc1c9f588; " QuickBlox-REST-API-版" =" 0.1.1&#34 ;; }
响应标头:{ "访问控制允许来源" =" *&#34 ;; "缓存控制" =" no-cache&#34 ;; 连接="保持活力&#34 ;; "内容类型" =" application / json;字符集= UTF-8&#34 ;; 日期="太阳,2015年2月1日18:59:19 GMT&#34 ;; " QB-令牌到期日期" UTC" 2015-02-01 20:57:39 UTC&#34 ;; " QuickBlox-REST-API-版" =" 0.1.1&#34 ;; 服务器=" nginx / 1.0.15&#34 ;; Status =" 422 Unprocessable Entity&#34 ;; "传送编码" =身份; " X-机架缓存" ="无效,通过&#34 ;; " X - 请求-ID" = 17331b69e1b7a38d8545629e241733c8; " X-运行" =" 0.013145&#34 ;; " X UA兼容" =" IE = Edge,chrome = 1&#34 ;; }
我使用了以下代码......
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];
}
答案 0 :(得分:1)
首先尝试通过删除(或注释掉)上述某个字段来更新用户对象,直到找到有问题的属性。你一次更新了这么多,你不知道哪一个导致了这个问题。
我怀疑登录属性是来源,因为我认为它是在注册时设置和修复的,因此之后无法更新。