【问题标题】:Error with GET method in JSONJSON 中的 GET 方法出错
【发布时间】:2013-11-04 00:21:38
【问题描述】:

我收到未经授权的 BBVA APIData 错误。我在 Xcode 中用作 Objective-C 来获取数据的代码是这样的:

NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

[request setURL:[NSURL URLWithString:@"https://api.bbva.com/apidatos/zones/cards_cube.json?date_min=201301&date_max=201307&group_by=week"]];

[request setHTTPMethod:@"GET"];

[request setValue:@"application/json;charset=UTF-8" forHTTPHeaderField:@"Authorization: Y2hvbWFsaS1hcHA6MGM2ZTljNjgxODNiZmUzOWY2OGJiYjY1NjZlZmU4ZTE3MzI0NTcyOQ=="];

NSURLResponse *response;

NSData *GETReply = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];

NSString *theReply = [[NSString alloc] initWithBytes:[GETReply bytes] length:[GETReply length] encoding: NSASCIIStringEncoding];

NSLog(@"Reply: %@", theReply);

这是我使用的文档:https://developer.bbva.com/api/api-datathon/section/api-reference

【问题讨论】:

    标签: ios json get


    【解决方案1】:

    我认为,在第 4 行,应该是

     [request setValue: Y2hvbWFsaS1hcHA6MGM2ZTljNjgxODNiZmUzOWY2OGJiYjY1NjZlZmU4ZTE3MzI0NTcyOQ== forHTTPHeaderField:@"Authorization:"];
    

    您可能必须删除“授权:”后的冒号

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多