MATLAB minimales HTTP-POST-Request-Beispiel

minimal_http_post.m
% URL definieren
url = 'https://httpbin.org/post';

% Zu sendende Daten
data = struct('name', 'John', 'age', 30);

% Daten ins JSON-Format umwandeln
jsonData = jsonencode(data);

% Anfrageoptionen festlegen
options = weboptions('RequestMethod', 'post', ...
                    'ContentType', 'json', ...
                    'MediaType', 'application/json');

% POST-Anfrage ausführen
response = webwrite(url, jsonData, options);

% Antwort anzeigen
disp(response)

Ähnliche Beiträge nach Kategorie: Matlab/Simulink