How to send data from a clientdataset via post in Delphi

Asked

Viewed 1,190 times

1

I am developing an application that I need to send data from a Clientdataset (Delphi) to a web system via Post. How should I proceed? Grateful.

  • How was this communication set up? Do you already have a Service for this ? The fact that you are wanting to post, I believe are authentication information, right ? If yes, it should be sent in the request header.

  • I’ll send it to a web system that I have access to. That would be it?

  • I want to send data from a table that is in a clientDataSet. It must be via post to get protected. The system is desktop.

  • Yeah, but I believe you should have a little REST server to make this kind of request. Maybe a Datasnap if your project is small, but I recommend using mORMot. This guy would communicate with your Webservice.

  • Dude, now I think I understand your question. You can use the Indy components to make some requests. I do not remember very well how they work, I will try to assemble a prototype and give a search. But basically, it can request an address, and you pass the information in the URL parameter.

  • Yes. I’ll try the Internet. Thank you.

Show 1 more comment

1 answer

2


Try it this way:

procedure TForm1.Button1Click(Sender: TObject);
var
  MyIdHTTP: TIdHTTP;
  oStringList: TStringList;
  sResponse: String;
begin
  oStringList := TStringList.Create;
  oStringList.Add('usuario=victor');
  oStringList.Add('senha=12345');

  MyIdHTTP := TIdHTTP.Create(nil);
  try
    sResponse := MyIdHTTP.Post('http://SeuEndereco...', oStringList);
  finally
    MyIdHTTP.Free;
    oStringList.Free;
  end;
end;

PS: If it’s https, just create one TIdSSLIOHandlerSocketOpenSSL and allocate to the property IOHandler of MyIdHTTP, and also make dlls available libeay32 and ssleay32, along with the executable.

  • The TringList is a list for connection, right? It will not be necessary to use login and password for receiving. The PHP system will use Rest to receive the information. Gratefully.

  • The receipt will go like this: http://williamdurand.fr/2012/08/02/rest-apis-with-symfony2-the-right-way/

  • No, the list is for you to pass the input parameters. If I go to make a query in google.com, do I feed the parameter "q" with the string I want to search for, e.g.: www.google.com/? q=Stackoverflow In this case, you would feed the list with "q=" + "Stackoverflow"

  • I understood and I think your answer is right. .

  • And then @fabricio_wm, it worked ?

  • Sorry. I thought I already gave you Feedback. It worked. Thank you very much.

  • Oops, very good then. Thanks

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.