使用uber rush API我已经成功创建了授权令牌。但是当我尝试创建引用时,我得到的是HTML页面。我正在从iOS Objective C发出http请求。这就是我发出http请求的方式:
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/v1/deliveries/quote", kLiveURL]]];
[request setHTTPMethod:@"POST"];
[request setValue:[NSString stringWithFormat:@"Bearer %@", [[NSUserDefaults standardUserDefaults] objectForKey:kUberRushAccessTokenKey]] forHTTPHeaderField:@"Authorization"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:[NSString stringWithFormat:@"%lul", (unsigned long)[jsonData length]] forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:jsonData];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (data) {
NSError *error;
NSDictionary *jsonResponse = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
if (error) {
NSLog(@"dataString: %@",[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
} else {
NSLog(@"jsonResponse: %@", jsonResponse);
}
} else {
NSLog(@"httpResponse: %@", response);
}
}];
提前感谢您的帮助:)