使用TIdHTTP的HTTP / 1.1 400错误请求

时间:2014-11-25 16:40:11

标签: post azure https

我有这段代码从Microsoft Azure DataMarket获取访问令牌,产生错误EIdHTTPProtocolException HTTP/1.1 400 Bad Request

procedure TADTranslator.GetAccessToken();
var
  HTTP1: TIdHTTP;
  ParamList: TStringList;

  Result: String;
begin
  ParamList := TStringList.Create;
  HTTP1 := TIdHTTP.Create;
  try
    HTTP1.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(HTTP1);
    HTTP1.HandleRedirects := True;
    //Result := HTTP1.Post('https://datamarket.accesscontrol.windows.net/v2/OAuth2-13', ParamList);
    Result := HTTP1.Get('https://datamarket.accesscontrol.windows.net/v2/OAuth2-13');

    FLangAccessToken := Result;
  finally
    HTTP1.Free;
    ParamList.Free;
  end;
end;

请帮帮我。我做错了什么?

1 个答案:

答案 0 :(得分:0)

我发现了问题,只要参数错误,就会出现此错误。麻烦拍摄非常不清楚。我不知道这是微软的错误还是HTTP问题。我希望有更明确的信息,例如“身份验证失败”。