http帖子中的Miss参数

时间:2013-12-31 01:11:17

标签: ios nsurlconnection

NSString * aToken = [[[NSUserDefaults standardUserDefaults] arrayForKey:@"accessToken"] firstObject];
NSString * post = [NSString stringWithFormat:@"code=%@", @"035571"];
NSData * postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString * postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest * request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"url"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
[request setValue:@"no-cache" forHTTPHeaderField:@"Cache-Control"];
[request setValue:[NSString stringWithFormat:@"Bearer %@", aToken] forHTTPHeaderField:@"Authorization"];
NSURLConnection *conn = [[NSURLConnection alloc]initWithRequest:request delegate:self];
[conn start];

错误是:{"error":"invalid_request","error_description":"Required field is missing. 'code'"}

如何解决?任何想法?

0 个答案:

没有答案