我尝试发送cid=@“value”作为授权头,使用NSMutableURLRequest
。但它抛出了一个错误。任何帮助都将不胜感激。下面是我的代码:
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"url"]];
[request setHTTPMethod:@"GET"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"value" forHTTPHeaderField:@"APIAccessKey"];
[request setValue:[NSString stringWithFormat:@"cid=\"%@\"", @"hdemPsqxVSVSJCRSt8PHmUHUyUtXk="] forHTTPHeaderField:@"Authorization"];
字符串
但API返回此错误:
<NSHTTPURLResponse: 0x7fff0a41de80> { URL: http://url } { status code: 401, headers {
"Cache-Control" = "no-cache";
"Content-Length" = 31;
"Content-Type" = "application/json; charset=utf-8";
Date = "Tue, 26 May 2015 11:36:50 GMT";
Expires = "-1";
"App-Authenticate" = "Basic Scheme='API' location='https:url";
Pragma = "no-cache";
Server = "Microsoft-IIS/7.5";
"X-AspNet-Version" = "4.0.30319";
"X-Powered-By" = "ASP.NET";
} }
型
2条答案
按热度按时间km0tfn4u1#
字符串
或者添加一个header:
型
os8fio9y2#
没有名为“APIPLICATION KEY”的HTTP头。因此,
字符串
你应该使用,
型