Hipolito Lopez
2008-04-24 00:38:55 UTC
I'm trying to do a post to a local url in my network using this
code, but I'm getting 401 error (HTTP/1.1 401 Unauthorized), what can I do? or search for? (the machine where I running this is out the domain)
TMemoryStream *aStream = new TMemoryStream();
TStringStream *StrStream = new TStringStream(NULL);
TStringList *a = new TStringList();
TIdURI *uri = new TIdURI("");
TIdMultiPartFormDataStream *Params = new TIdMultiPartFormDataStream();
Params->AddFormField("tarjeta", codta);
Params->AddFormField("tipo", tipo);
Params->AddFormField("monto", monto);
Params->AddFormField("cargo", cargo);
Params->AddFormField("idcajero", idcajero);
Params->AddFormField("cajero", cajero);
IdHTTP1->Request->Clear();
IdHTTP1->Request->BasicAuthentication = true;
IdHTTP1->Request->Username = txtUser->Text;
IdHTTP1->Request->Password = txtPwd->Text;
IdHTTP1->Post(txtUrl->Text, Params, aStream);
aStream->Seek(0, soFromBeginning);
aStream->SaveToStream(StrStream);
StrStream->Seek(0, soFromBeginning);
ShowMessage(StrStream->DataString);
delete a;
delete aStream;
delete Params;
delete uri;
delete StrStream;
code, but I'm getting 401 error (HTTP/1.1 401 Unauthorized), what can I do? or search for? (the machine where I running this is out the domain)
TMemoryStream *aStream = new TMemoryStream();
TStringStream *StrStream = new TStringStream(NULL);
TStringList *a = new TStringList();
TIdURI *uri = new TIdURI("");
TIdMultiPartFormDataStream *Params = new TIdMultiPartFormDataStream();
Params->AddFormField("tarjeta", codta);
Params->AddFormField("tipo", tipo);
Params->AddFormField("monto", monto);
Params->AddFormField("cargo", cargo);
Params->AddFormField("idcajero", idcajero);
Params->AddFormField("cajero", cajero);
IdHTTP1->Request->Clear();
IdHTTP1->Request->BasicAuthentication = true;
IdHTTP1->Request->Username = txtUser->Text;
IdHTTP1->Request->Password = txtPwd->Text;
IdHTTP1->Post(txtUrl->Text, Params, aStream);
aStream->Seek(0, soFromBeginning);
aStream->SaveToStream(StrStream);
StrStream->Seek(0, soFromBeginning);
ShowMessage(StrStream->DataString);
delete a;
delete aStream;
delete Params;
delete uri;
delete StrStream;