You are not resetting your stream's Position
back to 0 before posting it, you are not even posting the XML stream at all (you commented it out). You are also not taking character encoding into account, or replicating the same properties that you are passing to curl.
Try this:
procedure TRestObject.post( postURL:String; doc:IXMLDocument );
var
aStream: TMemoryStream;
data : TStringStream;
xmlString : String;
begin
aStream := TMemoryStream.Create;
try
http.HandleRedirects := True;
http.ReadTimeout := 50000;
// encoding
xmlString := doc.XML.Text;
ShowMessage(xmlString);
data := TStringStream.Create(xmlString, TEncoding.UTF8);
try
http.Request.ContentType := 'application/xml';
http.Request.Connection := 'close';
try
http.Post( postURL, data, aStream );
except
on E: EIdHTTPProtocolException do
ShowMessage('Protocol Exception (HTTP status '+ IntToStr(E.ErrorCode) +'): ' + E.Message);
on E: EIdSocketError do
ShowMessage('Socket Error ('+ IntToStr(E.LastError) +'): ' + E.Message);
on E: Exception do
ShowMessage('Exception (class '+ E.ClassName +'): ' + E.Message);
end;
finally
data.Free;
end;
finally
aStream.Free;
end;
end;