在ios中使用windows azure移动服务获取发布数据的错误

问题描述:

使用windows azure mobile service发送来自POST方法的数据。 获得响应错误响应在ios中使用windows azure移动服务获取发布数据的错误

message = "An error has occurred."

我POST方法和 数据字典是

NSDictionary *data = @{@"emailID": @"[email protected]", 
         @"userPhone": @"", 
         @"password": @"12345678", 
         @"id":@"", 
         @"signUpBy": [NSNumber numberWithInt:1]}; 

和API调用函数是

-(void)signUpCallAPI:(NSDictionary *)parameter{ 

// URL that calls into the Azure Service 
NSString *serviceUri = @"https://demo.azure-mobile.net/tables/SignUp"; 

// Convert to NSURL type 
NSURL *myURL = [NSURL URLWithString:serviceUri]; 

// Create a request object 
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:myURL              cachePolicy:NSURLRequestReloadIgnoringLocalCacheData 
               timeoutInterval:60]; 
NSError *error; 
NSData *jsonData = nil; 
if (parameter) 
    jsonData = [NSJSONSerialization dataWithJSONObject:parameter 
               options:NSJSONWritingPrettyPrinted 
               error:&error]; 
    // Modify http headers for POST request 
[request setHTTPMethod: @"POST"]; 

//Content type what we are sending 
[request setValue:[NSString stringWithFormat:@"%lu",(unsigned long)jsonData.length ] forHTTPHeaderField:@"content-length"]; 

// Indicate JSON Data Format 
[request setValue:@"application/json" forHTTPHeaderField:@"content-type"]; 

// Indicate JSON Data Format 
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; 


// Indicate host property 
[request setValue:@"demo.azure-mobile.net" forHTTPHeaderField:@"Host"]; 

// Indicate application key (you get this from the portal) 
[request setValue:@"demoappkey" forHTTPHeaderField:@"X-ZUMO-APPLICATION"]; 

//add data to body 
[request setHTTPBody:jsonData]; 

// Execute request 
conn= [[NSURLConnection alloc] initWithRequest:request delegate:self]; 
[conn start];} 

对于从注册API不工作后的数据。 有什么需要做我的身边? 任何样本可用于使用API​​的发布数据。

在此先感谢

看起来你正在尝试使用移动服务,而无需使用iOS的SDK。微软创造了可简化发送和从移动服务中检索数据的各种移动平台的SDK:https://github.com/Azure/azure-mobile-services

我建议你在待办事项样品iOS应用先来看看:https://azure.microsoft.com/en-us/documentation/articles/mobile-services-ios-get-started/

接下来,本文中的微软文档介绍了如何移动服务添加到现有的应用程序:https://azure.microsoft.com/en-us/documentation/articles/mobile-services-ios-get-started-data/

+1

葛亭Errordomain = com.Microsoft.WindowsAzureMobileServices.ErrorDomain代码= -1302“{”消息“:”发生错误“}”的UserInfo = {0x7f92a2ee8f60 NSLocalizedDescription = {“message”:“发生错误。”},com.Microsoft.WindowsAzureMobileServices.ErrorRequestKey = ... com.Mi crosoft.WindowsAzureMobileServices.ErrorResponseKey = {URL:https://demo.azure-mobile.net/tables/SignUp} {status code:500,headers { “Content-Length”= 36; “Content-Type”=“application/json; charset = utf-8”; Server =“Microsoft-IIS/8.0”; ..}} – Dhanraja

+0

使用Chrome导航到demo.azure-mobile.net/tables/SignUp返回:{ “code”:404, “error”:“错误:表'SignUp'不存在。 “ } – CSharpRocks

+1

演示词由我添加而不是真实的。很难找到错误代码-1302的问题,因为它只给出响应**消息“:”发生错误**。任何其他方式来找到哪一端(客户端或服务器)的问题? – Dhanraja