Delphi POST命令出错

Delphi POST命令出错,delphi,indy,delphi-6,idhttp,Delphi,Indy,Delphi 6,Idhttp,我的指挥部有问题。我正在Delphi6上使用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:='applic

我的指挥部有问题。我正在Delphi6上使用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);
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);
但我不知道如何使用令牌执行POST命令:

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);
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方法不允许


此错误意味着资源不接受HTTP POST请求,因此请确保source使用的是正确的请求类型。此外,发送请求时不应填充
TIdHTTP.Response
值。而且,发送
应用程序/x-www-form-urlencoded
格式化请求的正确方法是使用重载版本的
Post()
,它将
TStrings
作为输入,而不是
TStream
。而且,将Request.Accept设置为application/x-www-form-urlencoded显然是错误的。将
Request.Accept
设置为您愿意从服务器接受的媒体类型(如JSON),而不是发送到服务器的媒体类型。或者,不要设置
请求。完全接受
。谢谢你的回答,我可以发布帖子,但我不能发布,我添加了参数:=TStringList.Create;参数添加(EdPost.Text);Params.Add('.'方法=PUT');但是我有一个消息错误405方法不被允许,正如Remy所说,这个错误与您正在执行“post”http命令有关,这是服务器不接受的。尝试改用“TIdHttp.Put”。并使用“post”将您的问题标题表更改为“put”。