2016-01-10 36 views
0

我想实现一个错误报告页面到我的应用程序。用户提供了用户名和密码以及错误标题和描述,我做了REST(lol)。反正这是我的代码:创建新的问题GitHub iOS

+(void)reportBug:(NSString *)username password:(NSString *)password title:(NSString *)title description:(NSString *)body completion:(void (^)(id))completion{ 
    NSDictionary *myDict = @{@"body" : body, @"title" : title, @"assignee" : username}; 
    AFHTTPSessionManager *session = [[AFHTTPSessionManager alloc]initWithBaseURL:[NSURL URLWithString:@"https://api.github.com"] sessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]]; 
    [session POST:@"/repos/AFNetworking/AFNetworking/issues" parameters:myDict constructingBodyWithBlock:nil progress:nil success:^(NSURLSessionDataTask *task, id responseObject) { 
     NSLog(@"everything is %@", responseObject); 
    } failure:^(NSURLSessionDataTask *task, NSError *error) { 
    completion (error); 
    }]; 
} 

我真的没有找到的文档很清楚,但也许我只是愚蠢。我收到此错误:

Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: not found (404)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7f8a92a1de40> { URL: https://api.github.com/repos/AFNetworking/AFNetworking/issues } { status code: 404, headers { 
"Access-Control-Allow-Credentials" = true; 
"Access-Control-Allow-Origin" = "*"; 
"Access-Control-Expose-Headers" = "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"; 
"Content-Encoding" = gzip; 
"Content-Security-Policy" = "default-src 'none'"; 
"Content-Type" = "application/json; charset=utf-8"; 
Date = "Sun, 10 Jan 2016 16:20:51 GMT"; 
Server = "GitHub.com"; 
Status = "404 Not Found"; 
"Strict-Transport-Security" = "max-age=31536000; includeSubdomains; preload"; 
"Transfer-Encoding" = Identity; 
"X-Content-Type-Options" = nosniff; 
"X-Frame-Options" = deny; 
"X-GitHub-Media-Type" = "github.v3"; 
"X-GitHub-Request-Id" = "51AB3A71:12180:25A43C4:569284E3"; 
"X-RateLimit-Limit" = 60; 
"X-RateLimit-Remaining" = 46; 
"X-RateLimit-Reset" = 1452445261; 
"X-XSS-Protection" = "1; mode=block"; 
} }, NSErrorFailingURLKey=https://api.github.com/repos/AFNetworking/AFNetworking/issues, com.alamofire.serialization.response.error.data=<7b226d65 73736167 65223a22 4e6f7420 466f756e 64222c22 646f6375 6d656e74 6174696f 6e5f7572 6c223a22 68747470 733a2f2f 64657665 6c6f7065 722e6769 74687562 2e636f6d 2f76332f 69737375 65732f23 63726561 74652d61 6e2d6973 73756522 7d>, NSLocalizedDescription=Request failed: not found (404)} 
+0

不需要吗?因为那真的没有意义 –

+0

nvm,这是一个公共回购。 结果请求是什么样的?它看起来像API期待JSON,如果你发送NSDictionary而不是NSString,该怎么办? – shim

+0

是啊多数民众赞成在我的想法。我将如何将它转换成json并发送它? –

回答

1

您必须通过身份验证才能发布新问题。