req est une HTTPRequête
req.Méthode = httpPost
req.URL = "http://127.0.0.1:8082/pos/product"
req.Entête["Authorization"] = "Bearer sk_test_..."
req.Entête["Content-Type"] = "application/json"
req.Contenu = '{"name":"string","price":0,"category":"string"}'
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/pos/product");
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, '{"name":"string","price":0,"category":"string"}');
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/pos/product")
.header("Authorization", "Bearer sk_test_...")
.header("Content-Type", "application/json")
.body(r#"{"name":"string","price":0,"category":"string"}"#)
.send()
.await?;
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "http://127.0.0.1:8082/pos/product",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{"name":"string","price":0,"category":"string"}',
CURLOPT_HTTPHEADER => [
"Authorization: Bearer sk_test_...",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);