POST命令

时间:2018-04-16 09:58:47

标签: delphi indy delphi-6 idhttp

我遇到了POST命令的问题。我在Delphi 6上使用了Indy的TIdHTTP组件。

我使用此POST命令获得一个令牌:

URI:=EdUri.Text+Edit5.Text;   
Http1.Request.ContentType := 'application/x-www-form-urlencoded';
Http1.Request.Accept   := 'application/x-www-form-urlencoded';
Http1.Response.ContentType:='application/json';
Http1.Post(URI, Params, Resp);

然后我用令牌执行GET命令:

URI:=EdUri.Text;// := 'http://xx.xxx.xxx.xxx/';
Http1.Response.ExtraHeaders.Values['Authorization'] :='Bearer '+sTocken;
Http1.Request.ExtraHeaders.Values['Authorization'] :='Bearer '+sTocken;
Http1.get(URI+Chaine,  Resp);

但我不知道如何使用令牌执行POST命令:

Params := TStringStream.Create('code=''FF''&libelle=''test222''');
URI :='http://xxxx.xxx.xxx.xxx/Massi/pays/13';
Http1.Request.ContentType := 'application/x-www-form-urlencoded';
Http1.Request.Accept   := 'application/x-www-form-urlencoded';
Http1.Response.ContentType:='application/json';
Http1.Response.ExtraHeaders.Values['Authorization'] :='Bearer '+sTocken;
Http1.Request.ExtraHeaders.Values['Authorization'] :='Bearer '+sTocken;
Http1.Post(URI, Params, Resp);

我收到错误:

  

405方法不允许

0 个答案:

没有答案