我正在尝试发布声音以回声巢进行文件分析。POST 方法与任何其他方法没有什么不同,我相信它不依赖于 echonest。
这是文档。我需要“上传”部分。
http://developer.echonest.com/docs/v4/track.html
NSURLRequest *request = [self multipartFormRequestWithMethod:@"POST" path:[NSString stringWithFormat:@"track/upload", self.apiKey] parameters:dictionary constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:data name:@"track" fileName:[path lastPathComponent] mimeType:@"multipart/form-data"];
}];
AFURLConnectionOperation *operation = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"done");
NSLog(@"response: %@", operation.responseString);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"error: %@", error.description);
NSLog(@"response: %@", operation.responseString);
NSLog(@"headers: %@", operation.request.allHTTPHeaderFields.description);
NSLog(@"operation url: %@", operation.request.URL.absoluteString);
}];
但是,我有问题。这是我的回应:
{"response": {"status": {"version": "4.2", "code": 4, "message": "track - Missing Parameter: track or url is required with a POST content-type of \"application/x-www-form-urlencoded\" or \"multipart/form-data\""}}}
我以为我已经将“track”参数作为我初始化的数据。谁能帮我?