|Subject:||Re: HTTP/1.1 400 Bad Request|
|Posted by:||Remy Lebeau \(Indy Team\) (firstname.lastname@example.org)|
|Date:||Thu, 27 Sep 2007|
"Steve Mitchel" <ste…@eventpro.net> wrote in message
> Instead the line where I run my HttpConnection.Post raises
> an exception with the following error: "HTTP/1.1 400 Bad Request".
Then you are not uploading the data correctly.
> streamFormData.AddFile('comxmlfile', aFile, 'multipart/form-data');
That is not the correct ContentType value to use, and is likely what is
causing the server to fail. You need to use the file's actual ContentType,
which for XML is 'text/xml', ie:
streamFormData.AddFile('comxmlfile', aFile, 'text/xml');
streamFormData.AddFile('comxmlfile', aFile, GetMIMETypeFromFile(aFile));
'multipart/form-data' is the ContentType that Post() will apply to the
overall request for you. It does not belong on any of the individual
> Result := streamResponse.DataString;
Rather than using a TStringString manually, you can use Post()'s return
Result := HttpConnection.Post(TransferOptions.VenueCheck.Url,
That would be one less stream that you have to manage yourself.
HTTP/1.1 400 Bad Request posted by Steve Mitchel on Thu, 27 Sep 2007