我正在尝试使用Woocommerce v2 api和AFNetworking在Woocommerce上创建产品。这是我的代码:
NSURL *url = [NSURL URLWithString:@"https://clientappdownload.com"];
NSDictionary *authDict = @{@"consumer_key":consumerKey,@"consumer_secret":consumerSecret};
NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration];
AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc] initWithBaseURL:url sessionConfiguration:sessionConfig];
[manager setResponseSerializer:[AFJSONResponseSerializer serializer]];
[manager setRequestSerializer:[AFJSONRequestSerializer serializer]];
[manager POST:@"https://clientappdownload.com/NobleCents/wc-api/v2/products" parameters:authDict success:^(NSURLSessionDataTask *task, id responseObject) {
NSLog(@"success %@",responseObject);
} failure:^(NSURLSessionDataTask *task, NSError *error) {
NSLog(@"fail %@",error);
}];
但我一直收到错误:
fail Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: not found (404)" UserInfo=0x7ffbfb419b80 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7ffbfb6418a0> { URL: https://clientappdownload.com/NobleCents/wc-api/v2/products } { status code: 404, headers {
"Cache-Control" = "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
Connection = "Keep-Alive";
"Content-Encoding" = gzip;
"Content-Length" = 104;
"Content-Type" = "application/json; charset=UTF-8";
Date = "Mon, 29 Dec 2014 16:46:38 GMT";
Expires = "Thu, 19 Nov 1981 08:52:00 GMT";
"Keep-Alive" = "timeout=10, max=500";
Pragma = "no-cache";
Server = Apache;
"Set-Cookie" = "PHPSESSID=lldn4nq9fmmokrj19dd04rqvl5; path=/";
Vary = "Accept-Encoding";
} }, NSErrorFailingURLKey=https://clientappdownload.com/NobleCents/wc-api/v2/products, com.alamofire.serialization.response.error.data=<7b226572 726f7273 223a5b7b 22636f64 65223a22 776f6f63 6f6d6d65 7263655f 6170695f 61757468 656e7469 63617469 6f6e5f65 72726f72 222c226d 65737361 6765223a 22436f6e 73756d65 72204b65 79206973 206d6973 73696e67 227d5d7d>, NSLocalizedDescription=Request failed: not found (404)}
请帮帮我。