I am using QuickBlox iOS SDK (version 2.9.2) and got a failure with error code 422 when calling
[QBRequest createObject:qbcoCustomObject successBlock:^(QBResponse *response, QBCOCustomObject *object) {
} errorBlock:^(QBResponse *response) {
}];
It happens OCCASIONALLY and does not resume until I logout and login QuickBlox again.
The error message is as follows:
2017-04-24 06:18:45.855557 App[8720:4958563] [QBCore] Response error: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: client error (422)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x17422ed40> { URL: https://api.quickblox.com/data/MyCircleComments.json } { status code: 422, headers {
"Access-Control-Allow-Origin" = "*";
"Cache-Control" = "no-cache";
Connection = "keep-alive";
"Content-Length" = 45;
"Content-Type" = "application/json; charset=utf-8";
Date = "Mon, 24 Apr 2017 12:18:45 GMT";
"QB-Token-ExpirationDate" = "2017-04-24 14:09:35 +0000";
"QuickBlox-REST-API-Version" = "0.1.1";
Server = "openresty/1.9.15.1";
Status = "422 Unprocessable Entity";
"X-Rack-Cache" = "invalidate, pass";
"X-Request-Id" = 89f509abd6fd7f61d02e34ae9e83ce70;
"X-Runtime" = "0.009477";
"X-UA-Compatible" = "IE=Edge,chrome=1";
} }, NSErrorFailingURLKey=https://api.quickblox.com/data/MyCircleComments.json, com.alamofire.serialization.response.error.data=<7b226572 726f7273 223a7b22 62617365 223a5b22 466f7262 69646465 6e2e204e 65656420 75736572 2e225d7d 7d>, NSLocalizedDescription=Request failed: client error (422)}
2017-04-24 06:18:45.856659 App[8720:4958563] [QBCore] Response error reasons: {
errors = {
base = (
"Forbidden. Need user."
);
};
}
Due to the fact that it resumes only after I logout and login again, I was thinking that it may be related to session expiry. I added login method at the app's didFinishLaunching and didBecomeActive so that the app will automatically re-login to make sure the login session be valid. The login method I use is
[QBRequest logInWithUserLogin:sUsername password:sPassword successBlock:^(QBResponse *response, QBUUser *user) {
} errorBlock:^(QBResponse *response) {
}];
and by setting breakpoints I am sure each time the auto relogin did succeed.
However, app's auto-relogin does not work. The failure still happens occasionally and the only way out is logout and login manually.
I googled this issue and found a bunch of topic but none seems to meet my problem. (One post suggests that the time of device may not be synchronized but actually my iPhone is using the network time.)
Can anyone give me a hint why it fails and a solution is highly appreciated. Thanks in advance.