req est une HTTPRequête
req.Méthode = httpPost
req.URL = "http://127.0.0.1:8082/admin/tpe-target"
req.Entête["Authorization"] = "Bearer sk_test_..."
req.Entête["Content-Type"] = "application/json"
req.Contenu = '{"ip":"string","port":0}'
res est une HTTPRéponse = HTTPEnvoie(req)
SI ErreurDétectée ALORS
Erreur(ErreurInfo())
SINON
Trace(res.Contenu)
FIN
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "http://127.0.0.1:8082/admin/tpe-target");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Authorization: Bearer sk_test_...");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, '{"ip":"string","port":0}');
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
let client = reqwest::Client::new();
let res = client.post("http://127.0.0.1:8082/admin/tpe-target")
.header("Authorization", "Bearer sk_test_...")
.header("Content-Type", "application/json")
.body(r#"{"ip":"string","port":0}"#)
.send()
.await?;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "http://127.0.0.1:8082/admin/tpe-target",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"ip":"string","port":0}',
CURLOPT_HTTPHEADER => [
"Authorization: Bearer sk_test_...",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);