gpt4 book ai didi

ios - 当我将数据库任务拆分为不同的操作时,我无法使用 Objective c 和 Bluemix 将数据保存在 Cloudant 中,

转载 作者:行者123 更新时间:2023-11-29 02:00:51 31 4
gpt4 key购买 nike

我正在尝试将一个简单的对象(具有两个字符串属性的自定义类)从 iOS 应用程序存储在 Cloudant 数据库中。到目前为止,我正在尝试应用 IBM Bluemix 文档中的 objective c 编程语言示例。它不起作用,以防我在不同的操作中拆分 cloudant 任务。

存储对象的代码来自教程并已被重用。( https://www.ng.bluemix.net/docs/services/data/index.html )

对于身份验证,我使用了 bluemix 上的 Facebook 服务,这很有效。

cloudant 中的数据库由该代码成功自动创建:“autmobiledb”和“_users”,并且数据记录的创建也有效。

但是当我在不同的操作中拆分云计算任务时,它不起作用并且我得到了一些 nil 对象。

也许是这样,因为我是objective c的新手。

这是类结构:

  • 模型类(要保存的数据)

    CalcData、Automobile、Person、PersonSerializer

  • b) Controller 类(处理请求)

    汽车 Controller

  • c) View (在 iOS 设备上显示)

    View Controller

//创建到远程数据库的连接并存储示例数据 -> WORKS

- (void) setupIMFDatabase:(NSString *) dbname
{
// Get reference to data manager
IMFDataManager *manager = [IMFDataManager sharedInstance];
NSString *name = @"automobiledb"; //dbname;

// Information
NSLog(@"************** Inside Class 'setupIMFDatabase' ***************");

if( manager != nil )
{
NSLog(@"IMFDataManager is not NIL OK %@", manager.description);

if (self.datastore != nil)
{
NSLog(@"ERROR: self.datastore ");
}

// Create remote store
[manager remoteStore:name completionHandler:^(CDTStore *createdStore, NSError *error)
{

if(error){
// Handle error
NSLog(@"ERROR Time(%@): The REMOTE STORE can NOT be created because: %@", error.description);

}else{

CDTStore *store = createdStore;
NSLog(@"CDTStore created successfully: %@", store.name);
self.datastore = store;
NSLog(@"The self.datastore.name is %@ : ", self.datastore.name);

// Set permissions for current user on a store
// DB_ACCESS_GROUP_MEMBERS, DB_ACCESS_GROUP_ADMINS
[manager setCurrentUserPermissions: DB_ACCESS_GROUP_MEMBERS forStoreName: name completionHander:^(BOOL success, NSError *error) {
if(error){
// Handle error
NSLog(@"Cloudant User Permission ERROR: %@", error.description);
}else{
// setting permissions was successful
NSLog(@"No ERROR Description available - Cloudant User Permission OK");
}

if (success) {
// Handle error
NSLog(@"BOOLEAN CHECK: 'success == true' Cloudant User Permission");
} else {
// setting permissions was successful
NSLog(@"BOOLEAN CHECK: 'success == false' Cloudant User Permission");
}
}];

NSLog(@"INSIDE (Create remote store) the self.datastore is not NIL: %@", self.datastore.name);

CDTDataObjectMapper *mapper = (CDTDataObjectMapper*) self.datastore.mapper;
if (mapper != nil)
{
[mapper setDataType:@"CalcData" forClassName:@"CalcData" ];
NSLog(@"CDTDataObjectMapper is not NIL The description is: (%@)", mapper.description);
} else {
NSLog(@"ERROR: CDTDataObjectMapper IS NIL");
}

// Check the creation inside the setup if the database
CalcData* myCalcData = [[CalcData alloc] initWithValue:@"1+2=3" theID: @"12345"];
[self.datastore save:myCalcData completionHandler:^(id savedObject, NSError *error) {
NSLog(@"CHECK SAVE during the setup CALC DATA -- START ---");
if (error) {
// save was not successful, handler received an error
NSLog(@"The ERROR description is: (' %@ ')", error.description);
} else {
// use the result
CalcData *savedCalc = savedObject;
NSLog(@"The saved revision: %@", savedCalc);
NSLog(@"Data Saved: Value: %@ ID: %@", savedCalc.theCalcValue, savedCalc.theID);

}
NSLog(@"CHECK SAVE during the setup CALC DATA -- END ---");
}];


}
}];
} else {
NSLog(@"ERROR: IMFDataManager is NIL");
}

// Initialize the Mapper
if (self.datastore != nil)
{
NSLog(@"OUTSIDE self.datastore is not NIL: %@", self.datastore.name);

CDTDataObjectMapper *mapper = (CDTDataObjectMapper*) self.datastore.mapper;
if (mapper != nil)
{
NSLog(@"CDTDataObjectMapper is not NIL OK %@", mapper.description);
[mapper setDataType:@"CalcData" forClassName:@"CalcData" ];
} else {
NSLog(@"ERROR: CDTDataObjectMapper IS NIL");
}
} else {
NSLog(@"ERROR: self.datastore is NIL");
}
}

//将项目保存到 coudant -> 不起作用

- (void) createItem: (Automobile*) itemToStore
{
// Use an existing store
CDTStore *store = self.datastore;

if(store == nil)
{
NSLog(@"ERROR: The CDTStore inside 'createItem' is NIL");
return;
}

// The ObjectMapper must be a DataObjectMapper instance or a subclass
CDTDataObjectMapper *mapper = (CDTDataObjectMapper*) store.mapper;
if(mapper == nil)
{
NSLog(@"ERROR: The CDTDataObjectMapper nside 'createItem' is NIL");
return;
}

NSLog(@"TRY TO SAVE ITEM");


CalcData* myCalcData = [[CalcData alloc] initWithValue:@"1+2=3" theID: @"12345"];

NSLog(@"TRY TO SAVE ITEM: SetDataType");
[mapper setDataType:@"CalcData" forClassName:@"CalcData" ];

[store save:myCalcData completionHandler:^(id savedObject, NSError *error) {
NSLog(@"TRY TO CHECK SAVE RESULT CALC-- START ---");
// save was not successful, handler received an error
if (error) {
// save was not successful, handler received an error
NSLog(@"ERROR CAN NOT STORE DATA: %@", error.description);
} else {
// use the result
CalcData *savedCalc = savedObject;
NSLog(@"saved revision: %@", savedCalc);
NSLog(@"Data Saved: Value: %@ ID: %@", savedCalc.theCalcValue, savedCalc.theID);

}
NSLog(@"TRY TO CHECK SAVE RESULT CALC DATA -- END ---");
}];
}

//在 View 中使用 Controller

- (IBAction)saveToBlueMixClick:(id)sender {

NSLog(@"********************************* INIT CONTROLLER **************");
AutomobileController* myAutoController = [[AutomobileController alloc]init];

NSLog(@"********************************* INIT DATABASE **************");
NSString *name = @"automobiledb"; //dbname;
[myAutoController setupIMFDatabase:name];

NSLog(@"********************************* SAVE ITEM **************");
[myAutoController createItem:myAutomobile];
}
@end

调试信息:

2015-06-02 16:35:46.868 StoreInBlueMix[5618:2136563] ********************************* INIT CONTROLLER **************
2015-06-02 16:35:46.869 StoreInBlueMix[5618:2136563] ************************ INIT: AutomobileController DATABASE ***********************
2015-06-02 16:35:46.869 StoreInBlueMix[5618:2136563] ********************************* INIT DATABASE **************
2015-06-02 16:35:46.880 StoreInBlueMix[5618:2136597] [INFO] [IMFData] IMFDataAuthorizationManager initialized with scope (null)
2015-06-02 16:35:46.888 StoreInBlueMix[5618:2136597] [INFO] [IMFData] IMFDataAuthorizationManager registered as an NSURLProtocol
2015-06-02 16:35:46.896 StoreInBlueMix[5618:2136597] [INFO] [IMFData] IMFDataAuthorizationManager registering protected resource URL https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455
2015-06-02 16:35:46.932 StoreInBlueMix[5618:2136597] [INFO] [IMFData]

IMFDataManager initialized successfully:
CloudantToolkit Version: 1.0.0
CloudantToolkit Build Date: 20150309_1800
IMFData-Bluemix Version: 1.0.0
IMFData-Bluemix Build Date: 20150309_1800
Target URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455

2015-06-02 16:35:46.939 StoreInBlueMix[5618:2136563]

IMFDataManager initialized successfully:
CloudantToolkit Version: 1.0.0
CloudantToolkit Build Date: 20150309_1800
IMFData-Bluemix Version: 1.0.0
IMFData-Bluemix Build Date: 20150309_1800
Target URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455

2015-06-02 16:35:46.941 StoreInBlueMix[5618:2136563] ************** Inside Class 'setupIMFDatabase' ***************
2015-06-02 16:35:46.942 StoreInBlueMix[5618:2136563] IMFDataManager is not NIL OK <IMFDataManager: 0x14d8b980>
2015-06-02 16:35:46.943 StoreInBlueMix[5618:2136597] [INFO] [IMFData] remoteStore URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb
2015-06-02 16:35:46.952 StoreInBlueMix[5618:2136597] [INFO] [IMFData] CDTHttpHelper.sendHttpRequest:method:headers:payload:completionHandler: making HTTP request. Details:
URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb
Method: PUT
Headers:
2015-06-02 16:35:46.959 StoreInBlueMix[5618:2136563] ERROR: self.datastore is NIL
2015-06-02 16:35:46.961 StoreInBlueMix[5618:2136563] ********************************* SAVE ITEM **************
2015-06-02 16:35:46.962 StoreInBlueMix[5618:2136563] ERROR: The CDTStore inside 'createItem' is NIL
2015-06-02 16:35:46.969 StoreInBlueMix[5618:2136599] [INFO] [IMFData] IMFDataProtocol.sendRequestToProtectedResource: making HTTP request. Details:
URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb
Method: PUT
Headers:
Authorization : Bearer eyJh **** BIN DATA **** mSGGLrG4_yIBKA
2015-06-02 16:35:47.288 StoreInBlueMix[5618:2136599] [INFO] [IMFData] Authorization failure. Http status 401 received on request to https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb
2015-06-02 16:35:47.298 StoreInBlueMix[5618:2136599] [INFO] [IMFData] Authorization token invalid. Requesting new token.
2015-06-02 16:35:47.308 StoreInBlueMix[5618:2136599] [INFO] [IMFData] Authorization failure. Http status 401 received on request to https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb
2015-06-02 16:35:47.733 StoreInBlueMix[5618:2136620] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestRedirected:response:] in WLAFHTTPClientWrapper.m:235 :: Request Redirected to URL : http://localhost?code=FWO7lxoRjc20cmIG2J1F4xWHu6ErL85RP1maAgNXAC00N5Ao10nxEFXdNkhsDvrdRQFBeF3x-H6xXFaD4jiunp7SUoedMvjfh8fNcfMbYYTnoCCGhf-4bJ4-m9PLOkieu_a3QrEZew02ybFblXP23wJccHLIqWUMtlwGWkwLu-tWrsIsIKIq6dXeFoJfxltc&wl_result=%7B%22WL-Authentication-Success%22:%7B%22wl_facebookRealm%22:%7B%22userId%22:%22707109936101050%22,%22attributes%22:%7B%7D,%22isUserAuthenticated%22:1,%22displayName%22:%22Thomas+Nikolaus+Michael+S%22,%22deviceId%22:%22707109936101050%22%7D%7D%7D
2015-06-02 16:35:47.746 StoreInBlueMix[5618:2136620] [DEBUG] [IMF_OAUTH] -[IMFAuthorizationManager handleGrantCode:] in IMFAuthorizationManager.m:320 :: Grant code received successfully
2015-06-02 16:35:47.754 StoreInBlueMix[5618:2136620] [DEBUG] [IMF_OAUTH] -[IMFAuthorizationManager invokeTokenRequest] in IMFAuthorizationManager.m:326 :: Call token endpoint in order to obtain authorization token
2015-06-02 16:35:48.191 StoreInBlueMix[5618:2136620] [DEBUG] [CERTIFICATE_MANAGER] +[WLCertManager generateKeyPair:withPublicKeyLabel:withKeySize:] in WLCertManager.m:216 :: generateKeyPair generating keypair --> Success
2015-06-02 16:35:48.265 StoreInBlueMix[5618:2136620] [DEBUG] [IMF] -[IMFAuthorizationRequest makeRequestWithPath:options:] in IMFAuthorizationRequest.m:70 :: Building the request URL with path: authorization/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/token
2015-06-02 16:35:48.271 StoreInBlueMix[5618:2136620] [DEBUG] [IMF] +[WLAFHTTPClientWrapper requestWithURL:] in WLAFHTTPClientWrapper.m:44 :: Request url is https://storeinbluemix.eu-gb.mybluemix.net/imf-authserver/authorization/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/token
2015-06-02 16:35:48.280 StoreInBlueMix[5618:2136620] [DEBUG] [IMF_REQUEST] -[IMFAuthorizationRequest sendRequestToPath:path:withOptions:] in IMFAuthorizationRequest.m:115 :: Request timeout is 60.000000
2015-06-02 16:35:48.292 StoreInBlueMix[5618:2136620] [DEBUG] [IMF_REQUEST] -[IMFAuthorizationRequest sendRequestToPath:path:withOptions:] in IMFAuthorizationRequest.m:171 :: Sending request (https://storeinbluemix.eu-gb.mybluemix.net/imf-authserver/authorization/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/token) with headers:
{
"Accept-Language" = de;
"User-Agent" = "/StoreInBlueMix/1 (iPad; iOS 8.1.2; Scale/1.00)/IMFAPI";
"X-REWRITE-DOMAIN" = "eu-gb.bluemix.net";
"X-WL-Auth" = 1;
"X-WL-Authenticate" = "eyJhbGci *** BIN DATA +++7mmJZKt5xu-HnO72i-BGYpA==";
"X-WL-Session" = "0152FE04-CEC6-4F65-9148-B94F892A6CE8";
}
Post Data: code=FWO7lxoRjc20cmIG2J1F4xWHu6ErL85RP1maAgNXAC00N5Ao10nxEFXdNkhsDvrdRQFBeF3x-H6xXFaD4jiunp7SUoedMvjfh8fNcfMbYYTnoCCGhf-4bJ4-m9PLOkieu_a3QrEZew02ybFblXP23wJccHLIqWUMtlwGWkwLu-tWrsIsIKIq6dXeFoJfxltc&redirect_uri=http://localhost&grant_type=authorization_code&client_id=1e4bea3c407e37e13e517ff74031217fd8196d08
2015-06-02 16:35:48.306 StoreInBlueMix[5618:2136620] [DEBUG] [IMF] -[WLAFHTTPClientWrapper start] in WLAFHTTPClientWrapper.m:194 :: Starting the request with URL https://storeinbluemix.eu-gb.mybluemix.net/imf-authserver/authorization/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/token
2015-06-02 16:35:48.315 StoreInBlueMix[5618:2136620] [DEBUG] [IMF_REQUEST] -[IMFAuthorizationRequest sendRequestToPath:path:withOptions:] in IMFAuthorizationRequest.m:174 :: waiting for response... (Thread=<NSThread: 0x14e56c20>{number = 3, name = AFNetworking})
2015-06-02 16:35:48.335 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:215 :: Request Failed
2015-06-02 16:35:48.343 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:216 :: Response Status Code : 0
2015-06-02 16:35:48.351 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:217 :: Response Error : wl-oauth-prevent-redirect
2015-06-02 16:35:48.467 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:199 :: Request Success
2015-06-02 16:35:48.477 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:200 :: Response Status Code : 200
2015-06-02 16:35:48.485 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:201 :: Response Content : {"token_type":"bearer","expires_in":3600,"id_token":"eyJhbGciOiJSUzI1NiIsImpwayI6eyJhb * BIN DATA * hmh10l6PcoUVnr6njYk99pj8g0JQjIIONtaXj5e6zc1-0jcue0n-2f8DrryXvTYcKrKxOAScc890uGQo5UBqneMjhn01DmWsyIZ561lj8uvXlg4SAj3XdoWW5CNx8fcH1DnrfiNVDAhJg","access_token":"e ** BIN DATA ** X9Ck91whdZyatn40t8ZTb7O3K31BA"}
2015-06-02 16:35:48.505 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[IMFAuthorizationRequest requestFinished:] in IMFAuthorizationRequest.m:341 :: Response Header: {
Connection = "Keep-Alive";
"Content-Type" = "application/json;charset=UTF-8";
Date = "Tue, 02 Jun 2015 14:35:42 GMT";
"Transfer-Encoding" = Identity;
"X-Backside-Transport" = "OK OK";
"X-Cf-Requestid" = "5007bbfb-e8f8-436c-6b26-dd9a99308ac0";
"X-Client-IP" = "79.254.2.52";
"X-Global-Transaction-ID" = 1597951457;
"X-Powered-By" = "Servlet/3.0";
}
Response Data: {"token_type":"bearer","expires_in":3600,"id_token":"eyJ *** BIN DATA **** BA"}
Status code=200
2015-06-02 16:35:48.601 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper start] in WLAFHTTPClientWrapper.m:194 :: Starting the request with URL https://storeinbluemix.eu-gb.mybluemix.net/imfmobileanalytics/v1/receiver/apps/902f719f-f8a7-449f-ad4b-d50d48e68455
2015-06-02 16:35:48.611 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper start] in WLAFHTTPClientWrapper.m:194 :: Starting the request with URL https://storeinbluemix.eu-gb.mybluemix.net/imfmobileanalytics/v1/receiver/apps/902f719f-f8a7-449f-ad4b-d50d48e68455
2015-06-02 16:35:48.620 StoreInBlueMix[5618:2136601] [INFO] [IMFData] Obtained authorization header. Re-issueing request to https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb:
2015-06-02 16:35:48.629 StoreInBlueMix[5618:2136597] [INFO] [IMFData] IMFDataProtocol.sendRequestToProtectedResource: making HTTP request. Details:
URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb
Method: PUT
Headers:
Authorization : Bearer eyJhbGci * BIN DATA * vTYcKrKxOAScc890uGQo5UBqneMjhn01DmWsyIZ561lj8uvXlg4SAj3XdoWW5CNx8fcH1DnrfiNVDAhJg
2015-06-02 16:35:48.642 StoreInBlueMix[5618:2136563] [DEBUG] [IMF_OAUTH] -[IMFAuthorizationManager releaseCompletionHandlerQueue:error:] in IMFAuthorizationManager.m:428 :: Completion handlers queue released.
2015-06-02 16:35:48.649 StoreInBlueMix[5618:2136563] [DEBUG] [IMF_OAUTH] -[IMFAuthorizationManager clearCompletionHandlerQueue] in IMFAuthorizationManager.m:437 :: Completion handler queue cleared
2015-06-02 16:35:48.798 StoreInBlueMix[5618:2136600] [INFO] [IMFData] Response from server at https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb
Http Status: 412
Response Body:
{
error = "file_exists";
reason = "The database could not be created, the file already exists.";
}
2015-06-02 16:35:48.807 StoreInBlueMix[5618:2136600] [INFO] [IMFData] Cloudant create remote database response: Remote DB URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb
HTTP_Status: 412
JSON Body: {
error = "file_exists";
reason = "The database could not be created, the file already exists.";
}
2015-06-02 16:35:48.816 StoreInBlueMix[5618:2136632] CDTStore created successfully: automobiledb
2015-06-02 16:35:48.817 StoreInBlueMix[5618:2136632] The self.datastore.name is automobiledb :
2015-06-02 16:35:48.821 StoreInBlueMix[5618:2136600] [INFO] [IMFData] CDTHttpHelper.sendHttpRequest:method:headers:payload:completionHandler: making HTTP request. Details:
URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/_set_permissions
Method: POST
Headers:
Content-Type : application/json
Accept : application/json
Body:
{
access = members;
database = automobiledb;
identity = 707109936101050;
}
2015-06-02 16:35:48.828 StoreInBlueMix[5618:2136632] INSIDE (Create remote store) the self.datastore is not NIL: automobiledb
2015-06-02 16:35:48.830 StoreInBlueMix[5618:2136632] CDTDataObjectMapper is not NIL The description is: (<CDTDataObjectMapper: 0x14d81940>)
2015-06-02 16:35:48.834 StoreInBlueMix[5618:2136601] [INFO] [IMFData] CDTHttpHelper.sendHttpRequest:method:headers:payload:completionHandler: making HTTP request. Details:
URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb
Method: POST
Headers:
Content-Type : application/json
Accept : application/json
Body:
{
"@datatype" = CalcData;
theCalcValue = "1+2=3";
theID = 12345;
}
2015-06-02 16:35:48.846 StoreInBlueMix[5618:2136601] [INFO] [IMFData] IMFDataProtocol.sendRequestToProtectedResource: making HTTP request. Details:
URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/_set_permissions
Method: POST
Headers:
Authorization : Bearer eyJh ** BIN DATA ** fuvXlg4SAj3XdoWW5CNx8fcH1DnrfiNVDAhJg
Content-Type : application/json
Accept : application/json
Body:
{
access = members;
database = automobiledb;
identity = 707109936101050;
}
2015-06-02 16:35:48.858 StoreInBlueMix[5618:2136601] [INFO] [IMFData] IMFDataProtocol.sendRequestToProtectedResource: making HTTP request. Details:
URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb
Method: POST
Headers:
Authorization : Bearer eyJhbGciOi ** BIN DATA ** iNVDAhJg
Content-Type : application/json
Accept : application/json
Body:
{
"@datatype" = CalcData;
theCalcValue = "1+2=3";
theID = 12345;
}
2015-06-02 16:35:48.987 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:199 :: Request Success
2015-06-02 16:35:48.994 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:200 :: Response Status Code : 201
2015-06-02 16:35:48.999 StoreInBlueMix[5618:2136632] [INFO] [IMFData] Response from server at https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/_set_permissions
Http Status: 200
Response Body:
{
message = "IMFCP022I: F\U00fcr den Benutzer 707109936101050 gibt es bereits die Berechtigung f\U00fcr die Datenbank automobiledb.";
status = OK;
}
2015-06-02 16:35:49.006 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFinished:] in WLAFHTTPClientWrapper.m:201 :: Response Content : {}
2015-06-02 16:35:49.014 StoreInBlueMix[5618:2136632] [INFO] [IMFData] Set permissions response: Remote Index URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/_set_permissions
HTTP_Status: 200
JSON Body: {
message = "IMFCP022I: F\U00fcr den Benutzer 707109936101050 gibt es bereits die Berechtigung f\U00fcr die Datenbank automobiledb.";
status = OK;
}
2015-06-02 16:35:49.024 StoreInBlueMix[5618:2136600] No ERROR Description available - Cloudant User Permission OK
2015-06-02 16:35:49.025 StoreInBlueMix[5618:2136600] BOOLEAN CHECK: 'success == true' Cloudant User Permission
2015-06-02 16:35:49.040 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:215 :: Request Failed
2015-06-02 16:35:49.050 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:216 :: Response Status Code : 500
2015-06-02 16:35:49.059 StoreInBlueMix[5618:2136563] [DEBUG] [IMF] -[WLAFHTTPClientWrapper requestFailed:error:] in WLAFHTTPClientWrapper.m:217 :: Response Error : Expected status code in (200-299), got 500
2015-06-02 16:35:49.081 StoreInBlueMix[5618:2136563] [OCLogger] Request to send analytics data has failed.
2015-06-02 16:35:49.240 StoreInBlueMix[5618:2136632] [INFO] [IMFData] Response from server at https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb
Http Status: 201
Response Body:
{
id = 32d92f7601ef00e7a95df62a4c2983c0;
ok = 1;
rev = "1-dcf9fa05185806284b4d73996540e7b2";
}
2015-06-02 16:35:49.251 StoreInBlueMix[5618:2136632] [INFO] [IMFData] Cloudant create document response. Remote URL: https://mobile.eu-gb.bluemix.net/imfdata/api/v1/apps/902f719f-f8a7-449f-ad4b-d50d48e68455/automobiledb
HTTP_Status: 201
JSON Body: {
id = 32d92f7601ef00e7a95df62a4c2983c0;
ok = 1;
rev = "1-dcf9fa05185806284b4d73996540e7b2";
}
2015-06-02 16:35:49.261 StoreInBlueMix[5618:2136601] CHECK SAVE during the setup CALC DATA -- START ---
2015-06-02 16:35:49.262 StoreInBlueMix[5618:2136601] The saved revision: <CalcData: 0x14e92a60>
2015-06-02 16:35:49.263 StoreInBlueMix[5618:2136601] Data Saved: Value: 1+2=3 ID: 12345
2015-06-02 16:35:49.263 StoreInBlueMix[5618:2136601] CHECK SAVE during the setup CALC DATA -- END ---

最佳答案

根据日志,它看起来有效。根据您的日志语句,我看到以下内容:

Print "ERROR: OK    Cloudant User Permission", if error is nil.
Print "SUCCESS: Error Cloudant User Permission", if success is YES/TRUE.

日志语句仅显示create db 和设置permissions 片段,在提供日志之前我无法评论save Object .

关于ios - 当我将数据库任务拆分为不同的操作时,我无法使用 Objective c 和 Bluemix 将数据保存在 Cloudant 中,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30411542/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com