Created
May 19, 2022 18:32
-
-
Save an01f01/b16f0133e9d9b4db0c963af100325f0f to your computer and use it in GitHub Desktop.
A free pascal sample post procedure in a TForm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| procedure TForm1.OnPost(Sender: TObject); | |
| begin | |
| { Translate text test } | |
| httpClient := TFPHTTPClient.Create(nil); | |
| httpClient.RequestBody := TRawByteStringStream.Create(Memo1.Text); | |
| ResponseRest := TStringStream.Create(''); | |
| try | |
| try | |
| httpClient.Post('<REPLACE WITH YOUR URL TO REST POST API>', ResponseRest); | |
| Memo2.Lines.Add('Response Code is ' + inttostr(httpClient.ResponseStatusCode)); | |
| Memo2.Lines.Add(httpClient.ResponseStatusText); | |
| Memo2.Lines.Add(ResponseRest.DataString); | |
| except on E:Exception do | |
| Memo2.Lines.Add('something bad happened : ' + E.Message); | |
| end; | |
| finally | |
| httpClient.RequestBody.Free; | |
| httpClient.Free; | |
| end; | |
| end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
{
"to": "ja",
"from": "en",
"audio": false,
"text": "this is my name"
}