我正在從Microsoft Azure移動服務for iOS更新示例Todo應用程序,以使用表格存儲而不是默認MSSQL後端。此刻,當我嘗試插入一個新的項目,我收到以下錯誤客戶端:Azure iOS移動客戶端:服務器未返回預期項目
2014-11-22 11:06:44.895 xxx[6942:869598] ERROR Error Domain=com.Microsoft.WindowsAzureMobileServices.ErrorDomain Code=-1201 "The server did not return the expected item." UserInfo=0x7a6b1040 {NSLocalizedDescription=The server did not return the expected item., com.Microsoft.WindowsAzureMobileServices.ErrorResponseKey=<NSHTTPURLResponse: 0x7a764cc0> { URL: https://xxx.azure-mobile.net/tables/TodoItem } { status code: 200, headers {
"Cache-Control" = "no-cache";
"Content-Encoding" = gzip;
"Content-Length" = 126;
"Content-Type" = "application/json";
Date = "Sat, 22 Nov 2014 19:06:44 GMT";
Server = "Microsoft-IIS/8.0";
Vary = "Accept-Encoding";
"X-Powered-By" = "ASP.NET";
"x-zumo-version" = "Zumo.master.0.1.6.4100.Runtime";
} }, com.Microsoft.WindowsAzureMobileServices.ErrorRequestKey=<NSMutableURLRequest: 0x7a7797a0> { URL: https://xxx.azure-mobile.net/tables/TodoItem }}
我並沒有改變客戶端代碼。 https://github.com/Azure/azure-mobile-services/blob/master/sdk/iOS/src/MSJSONSerializer.m的文檔提示此錯誤是'errorForExpectedItem'錯誤,並且它在itemFromData:withOriginalItem:ensureDictionary:orError:中被拋出。
這個錯誤開始發生,因爲我試圖讓todoitem.read.js腳本工作;我至今無法從該腳本中取回可用的實體。這是我現在的todoitem.read.js:
var azure = require('azure-storage');
var tableSvc = azure.createTableService();
function read(query, user, request) {
query = new azure.TableQuery()
.select()
.where('PartitionKey eq ?', 'learningazure');
console.log('query: ', query);
tableSvc.queryEntities('TodoItem',query, null, function(error, result, response) {
if(!error) {
// query was successful
// add the count to the response dictionary
response.count = response.body.value.length;
response.results = result.entries;
request.respond(200, response);
} else {
console.log('Error calling read()');
console.log(error);
}
});
}
有什麼建議嗎?
如果您發現如何將數據返回給iOS客戶端,請分享!將不勝感激。 :d – weienw 2015-01-19 20:17:44