2013-11-04 63 views
1

我收到未經授權的BBVA APIData錯誤。使用了Xcode作爲Objective-C的用於獲取數據的代碼林是這樣的:JSON中的GET方法出錯

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

回答

0

我認爲,在第4行,它應該是

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

您可能必須在「授權」後刪除冒號: