Uber rush API返回html页面作为回应

时间:2016-10-18 18:00:33

标签: ios objective-c uber-api

使用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);
    }
}];

提前感谢您的帮助:)

0 个答案:

没有答案