NSURLERRORDOMAIN - 1012E :( null)在Bluemix上

时间:2015-06-01 16:11:13

标签: ios swift ibm-cloud

我正在尝试连接Bluemix远程数据库,如下所示:

IMFDataManager.sharedInstance().remoteStore("people", completionHandler: { (store:CDTStore!, error:NSError!) -> Void in

        var query:CDTCloudantQuery = CDTCloudantQuery(dataType: "Person")

        store.performQuery(query, completionHandler: { (results:[AnyObject]!, error:NSError!) -> Void in

            var myData = results as! [Person]
            println(myData.count)
        })
    })

由于某种原因,我收到以下错误消息。

我检查了文档,找不到任何与身份验证相关的内容。

2015-06-01 19:05:38.672 helloBluemix[34398:2621801] [INFO] [IMFData] Authorization failure.  Http status 401 received on request to https://mobile.ng.bluemix.net/imfdata/api/v1/apps/5fc5cfd9-73db-432b-a1f5-3f2824e1c5ec/peoples/_find
2015-06-01 19:05:38.676 helloBluemix[34398:2621799] [ERROR] [IMFData] Error occured during query.  URL: https://mobile.ng.bluemix.net/imfdata/api/v1/apps/5fc5cfd9-73db-432b-a1f5-3f2824e1c5ec/peoples/_find.  queryJSON: {
    selector =     {
        "@datatype" = Person;
    };
} NSURLERRORDOMAIN--1012E: (null)

2 个答案:

答案 0 :(得分:0)

这里也有同样的问题。

我对我的代码进行了一些更改,但无法想到我在Bluemix交互代码中更改的内容...... 当我之前有授权错误时,我能够通过在“Cloudant Dashboard”中调整数据库的访问权限来修复它。但是,它现在被设置为“Read”和“Write”for“Everybody”,所以这应该不是问题。

答案 1 :(得分:0)

在我获得对IMFDataManager对象的引用之后,我在获取相同的错误之前得到了相同的错误:

IMFDataManager *manager = [IMFDataManager sharedInstance];
[manager remoteStore:@"<your_db_name>" completionHandler:^(CDTStore *store, NSError *error) {
    if (error) {
        NSLog(@"there was an error fetching or creating the remote store");
    } else {
        NSLog(@"remote store success");
        [manager setCurrentUserPermissions:DB_ACCESS_GROUP_MEMBERS forStoreName:@"<your_db_name>" completionHander:^(BOOL success, NSError *error) {
            if (error) {
                NSLog(@"error setting permissions");
            } else {
                NSLog(@"set permissions successfully");
            }
            }];
        }
}];