ScHttpWebRequest Example
-
- Posts: 18
- Joined: Mon 28 Nov 2011 18:04
- Location: Türkiye
ScHttpWebRequest Example
hi, I could not find the example on the internet. how can i use it? is there a sample that makes an xml post on a host? thank you..
Re: ScHttpWebRequest Example
To solve the task, you can use the following code:
Code: Select all
var
Request: TScHttpWebRequest;
Response: TScHttpWebResponse;
ResponseStr: string;
...
Request := TScHttpWebRequest.Create('http://services.odata.org/Northwind/Northwind.svc/Orders()');
try
Response := Request.GetResponse;
try
ResponseStr := Response.ReadAsString;
Memo.Lines.Text := ResponseStr;
finally
Response.Free;
end;
finally
Request.Free;
end;
-
- Posts: 18
- Joined: Mon 28 Nov 2011 18:04
- Location: Türkiye
Re: ScHttpWebRequest Example
Thank you for the answer. where is this "ScHttpWebRequest" used? can I POST a file to a webpage?
Re: ScHttpWebRequest Example
Yes,could we send the files by https using SB ? I hope you can add this features in the future!!
Or you can add a new example of https with SB and Indy/RTC/kbmmw, etc. Thanks!
Or you can add a new example of https with SB and Indy/RTC/kbmmw, etc. Thanks!
-
- Posts: 18
- Joined: Mon 28 Nov 2011 18:04
- Location: Türkiye
Re: ScHttpWebRequest Example
yes, #stlcours. I agree with you. Thanks!
Re: ScHttpWebRequest Example
The HTTP protocol is not directly designed for transferring files. TScHttpWebRequest allows you to transfer data using the POST query method.
To solve the task, you can use the following code:
To solve the task, you can use the following code:
Code: Select all
var
Request: TScHttpWebRequest;
Response: TScHttpWebResponse;
ResponseStr: string;
Buf: TBytes;
begin
Request := TScHttpWebRequest.Create(URL);
try
Request.Method := rmPost;
Buf := TEncoding.UTF8.GetBytes('This is a test that posts this string to a Web server.');
Request.ContentType := 'application/x-www-form-urlencoded';
Request.ContentLength := Length(Buf);
Request.WriteBuffer(Buf);
Response := Request.GetResponse;
Response.Free;
finally
Request.Free;
end;
end;
Last edited by ViktorV on Fri 08 Dec 2017 10:55, edited 1 time in total.
-
- Posts: 18
- Joined: Mon 28 Nov 2011 18:04
- Location: Türkiye
Re: ScHttpWebRequest Example
Thank you for the answer. I will reach the solution. Can it be done at Basic Authorization? the following did not work.
Request := TScHttpWebRequest.Create('https://user:[email protected]/xml');
Request := TScHttpWebRequest.Create('https://user:[email protected]/xml');
Re: ScHttpWebRequest Example
Yes, SecureBridge allows executing the specified query. Please make sure that you are using the correct URL query and inform whether this query is executed if you input it in the browser address line.
-
- Posts: 2
- Joined: Mon 26 Nov 2018 14:57
Re: ScHttpWebRequest Example
I’m testing the Devart “SecureBridge” to be able to snoop and extract web content via https. My intention is to login to a site, click on a report button and download the excel csv file that I will get in return to my local computer. As far as I understand this will be possible to do with the “SecureBridge” components.
As a first step I did the example given by ViktorV » Tue 28 Nov 2017 16:30 in the thread as shown below. However I get this error: “Invalid class typecast” at the line: “Response := Request.GetResponse;”. Why is that? Can anyone give me an advice…
Regards
Bo
As a first step I did the example given by ViktorV » Tue 28 Nov 2017 16:30 in the thread as shown below. However I get this error: “Invalid class typecast” at the line: “Response := Request.GetResponse;”. Why is that? Can anyone give me an advice…
Regards
Bo
Code: Select all
unit CsvMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, ScHttp, ScSSHClient, Vcl.StdCtrls, Vcl.Buttons;
type
TForm2 = class(TForm)
BbtnTest: TBitBtn;
Memo1: TMemo;
procedure BbtnTestClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
Request: TScHttpWebRequest;
Response: TScHttpWebResponse;
ResponseStr: string;
implementation
{$R *.dfm}
procedure TForm2.BbtnTestClick(Sender: TObject);
begin
Request := TScHttpWebRequest.Create('https://esta.cbp.dhs.gov/esta/');
try
Response := Request.GetResponse;
try
ResponseStr := Response.ReadAsString;
Memo1.Lines.Text := ResponseStr;
finally
Response.Free;
end;
finally
Request.Free;
end;
end;
end.
Re: ScHttpWebRequest Example
Unfortunately, we can't reproduce the issue on the last SecureBridge 8.2.4 version. When executing the specified code, we do not get an error.
Please check whether the issue is reproduced on the latest version of SecureBridge 8.2.4 If it is, please compose a full sample demonstrating the described behavior and send it to us via form e-support: https://www.devart.com/company/contactform.html, including the scripts for creating and filling database objects. Also, please specify the IDE version you are using.
Please check whether the issue is reproduced on the latest version of SecureBridge 8.2.4 If it is, please compose a full sample demonstrating the described behavior and send it to us via form e-support: https://www.devart.com/company/contactform.html, including the scripts for creating and filling database objects. Also, please specify the IDE version you are using.
-
- Posts: 2
- Joined: Mon 26 Nov 2018 14:57
Re: ScHttpWebRequest Example
Thanks VictorV. I have filed a support ticket on the issue...
/Bo
/Bo
Re: ScHttpWebRequest Example
Thank you for the information. We have reproduced the issue and it will be fixed in the next build.