HTTP_Post
Performs an HTTP POST request to the specified URL with the given data and returns the response body.
URL — the URL to send the request to.
PostData — the data to include in the POST body.
The return value is the response body text. After the request, HTTP_Header also contains the response body and HTTP_Body contains the response headers (see the historical name swap notes on those methods).
If the hostname cannot be resolved, the method logs an error to the system journal and returns an empty string.
PascalScript supports the TStringList form only. DWScript supports both the TStringList form and an additional overload accepting a plain String.
Выполняет HTTP POST-запрос по указанному URL с переданными данными и возвращает тело ответа.
URL — адрес запроса.
PostData — данные для тела POST-запроса.
Возвращаемое значение — текст тела ответа. После запроса HTTP_Header также содержит тело ответа, а HTTP_Body — заголовки (см. примечания об исторической путанице имён в этих методах).
Если имя хоста не удаётся разрешить, метод записывает ошибку в системный журнал и возвращает пустую строку.
PascalScript поддерживает только форму с TStringList. DWScript поддерживает как форму с TStringList, так и дополнительную перегрузку, принимающую простую String.
function HTTP_Post(URL: String; PostData: TStringList): String;
function HTTP_Post(URL: String; PostData: TStringList): String;
DWS overload:
function HTTP_Post(URL: String; PostData: String): String;
def HTTP_Post(URL: str, PostData: str) -> str: ...
TStringList variant (works in both PS and DWS):
var
Params: TStringList;
Response: String;
begin
Params := TStringList.Create;
Params.Add('key=value');
Params.Add('name=test');
Response := HTTP_Post('https://httpbin.org/post', Params);
AddToSystemJournal('Response: ' + Response);
Params.Free;
end.
String variant (DWS only):
var
Response: String;
begin
Response := HTTP_Post('https://httpbin.org/post', 'key=value&name=test');
AddToSystemJournal('Response: ' + Response);
end.
response = HTTP_Post('https://httpbin.org/post', 'key=value&name=test')
AddToSystemJournal(f'Response: {response}')