|Subject:||HTTP/1.1 400 Bad Request|
|Posted by:||Steve Mitchel (ste…@eventpro.net)|
|Date:||Thu, 27 Sep 2007|
I have some code that posts an xml file up to a website along with a user
name and password. When all goes well the web site returns a success in the
response "Status S10: OK". When the web site finds the file is in error is
sends one of many possible errors codes in the response, except I never get
that response. Instead the line where I run my HttpConnection.Post raises an
exception with the following error: "HTTP/1.1 400 Bad Request". The errors
that are being sent from the web site look like they are formatted the same
as the success (ie: "Error E20: Access denied").
I use the BDS 2006 with Indy 10.1.5.
Does anyone know what I may be doing wrong. Below is a simple version of the
code I run.
function TransferXML(aFile, aUser, aPassword: String): string;
streamFormData := TIdMultiPartFormDataStream.Create;
streamResponse := TStringStream.Create('');
streamFormData.AddFile('comxmlfile', aFile, 'multipart/form-data');
streamFormData.Position := 0;
HttpConnection := TIdHttp.Create;
// the following line raises the exception if the response is
// to be an error code but runs fine when the response is a
streamResponse.Position := 0;
Result := streamResponse.DataString;