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)}
不需要嗎?因爲那真的沒有意義 –
nvm,這是一個公共回購。 結果請求是什麼樣的?它看起來像API期待JSON,如果你發送NSDictionary而不是NSString,該怎麼辦? – shim
是啊多數民衆贊成在我的想法。我將如何將它轉換成json併發送它? –