Problems regarding a HTTP.Post and TIdMultiPartFormDataStream

Giganews Newsgroups
Subject: Problems regarding a HTTP.Post and TIdMultiPartFormDataStream
Posted by:  R. Hoek (ho…@componentagro.nl)
Date: Wed, 1 Jun 2005

I'm trying to send some XML-data to a server using a post command.
First I'll show you the HTMl-equivalent for this:

<HTML>
    <head><title>J2ME HTML GET/POST Example</title></head>
    <body>
        <H1>POST Example</H1>
        <form action="http://test.mydomain.com/oai/servlet/transportServlet"
method="POST">
          Text: <TextArea name="message" cols=60 rows=10></Textarea>
            <p>
            <input type="Submit" name="submit" value="Post">
        </form>
    </body>
</HTML>

As you can see, there's only 1 field called "message" which is a TEXTAREA
(should be the same a TEXT not ??).
Below is the code I use to send it using the MultiPartFormData
streamopbject:

      _Data := TIdMultiPartFormDataStream.Create;
      _RespContent := TStringStream.Create('transportXML');
      try
        _Data.AddFormField('message', FMsgData);
        FHTTP.Post(sSendMessagePostURL, _Data, _RespContent);  //
sSendMessagePostURL same as in "action" of <Form>
        // It won't come here ...
        SetResponse(_RespContent.DataString);
      finally
        FreeAndNil(_Data);
        FreeAndNil(_RespContent);
      end;

Only then it return HTML reponse error "HTTP/1.1 400 Bad Request"...
Any idea of what's going wrong? Using the HTML version in IE and pasting the
FMsgData in the TEXTAREA wordks fine...

--
Regards,

Ronald Hoek

Applicationdevelopper
ComponentAgro B.V.

Replies