Como posso usar o Tidhttp para fazer uma solicitação Get com um parâmetro chamado xml?
Eu tenho usado com sucesso o Delphi 2010 para fazer um pedido get http, mas para um serviço que espera um parâmetro chamado 'xml' a solicitação falha com um erro 'HTTP / 1.1 400 Bad Request'.
Percebo que chamar o mesmo serviço e omitir o parâmetro 'xml' funciona.
Eu tentei o seguinte sem sucesso:
HttpGet('http://localhost/Service/Messaging.svc/SendReports/PDF?xml=<?xml version="1.0"?><email><message><to>email@internal.com</to><from>from@internal.com</from></message></email>&id=42&profile=A1');
...
function TReportingFrame.HttpGet(const url: string): string;
var
responseStream : TMemoryStream;
html: string;
HTTP: TIdHTTP;
begin
try
try
responseStream := TMemoryStream.Create;
HTTP := TIdHTTP.Create(nil);
HTTP.OnWork:= HttpWork;
HTTP.Request.ContentType := 'text/xml; charset=utf-8';
HTTP.Request.ContentEncoding := 'utf-8';
HTTP.HTTPOptions := [hoForceEncodeParams];
HTTP.Request.CharSet := 'utf-8';
HTTP.Get(url, responseStream);
SetString(html, PAnsiChar(responseStream.Memory), responseStream.Size);
result := html;
except
on E: Exception do
Global.LogError(E, 'ProcessHttpRequest');
end;
finally
try
HTTP.Disconnect;
except
end;
end;
end;
Chamar o mesmo URL com o nome do parâmetro 'xml' renomeado para qualquer outra coisa, como 'xml2' ou 'name' com o mesmo valor acima também funciona. Eu também tentei várias combinações do charset, mas acho que o componente indy está mudando internamente.
EDITAR
O serviço espera:
[WebGet(UriTemplate = "SendReports/{format=pdf}?report={reportFile}¶ms={jsonParams}&xml={xmlFile}&profile={profile}&id={id}")]
Alguém já teve alguma experiência com isto?
obrigado