OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"userIds\":[\"hrgpl0001\"]}");
Request request = new Request.Builder()
.url("https://{host}/api/logout")
.method("POST", body)
.addHeader("Authorization", "Basic TWpNQ0JSM1NFYnBrYXdSNTpNak1DQlIzU0VicGthd1I1")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://{host}/api/logout");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic TWpNQ0JSM1NFYnBrYXdSNTpNak1DQlIzU0VicGthd1I1");
request.AddHeader("Content-Type", "application/json");
var body = @"{\"userIds\":[\"hrgpl0001\"]}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
var myHeaders = new Headers();
myHeaders.append("Authorization", "Basic TWpNQ0JSM1NFYnBrYXdSNTpNak1DQlIzU0VicGthd1I1");
myHeaders.append("Content-Type", "application/json");
var raw = "{\"userIds\":[\"hrgpl0001\"]}";
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://{host}/api/logout", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
import http.client
import json
conn = http.client.HTTPSConnection("{host}")
payload = "{\"userIds\":[\"hrgpl0001\"]}"
headers = {
'Authorization': 'Basic TWpNQ0JSM1NFYnBrYXdSNTpNak1DQlIzU0VicGthd1I1',
'Content-Type': 'application/json'
}
conn.request("POST", "https://{host}/api/logout", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://{host}/api/logout"
method := "POST"
payload := "{\"userIds\":[\"hrgpl0001\"]}"
client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "Basic TWpNQ0JSM1NFYnBrYXdSNTpNak1DQlIzU0VicGthd1I1")
req.Header.Add("Content-Type", "application/json")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://{host}/api/logout');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'Authorization' => 'Basic TWpNQ0JSM1NFYnBrYXdSNTpNak1DQlIzU0VicGthd1I1',
'Content-Type' => 'application/json'
));
$request->setBody("{\"userIds\":[\"hrgpl0001\"]}");
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}