Request cURL Python Node.js Java Go
Copy curl -X POST \
'http://localhost:8080/lokta-lms/api/v1/taxes/component' \
-u '{username}:{password}' \
-H 'Tenant-Identifier: default' \
-H 'Content-Type: application/json' \
-d '{
"creditAccountId": 4,
"creditAccountType": 4,
"dateFormat": "dd MMMM yyyy",
"debitAccountId": 4,
"debitAccountType": 2,
"locale": "en",
"name": "tax component 1",
"percentage": 10,
"startDate": "11 April 2016"
}'
import requests
response = requests.post(
"http://localhost:8080/lokta-lms/api/v1/taxes/component",
auth=("{username}", "{password}"),
headers={"Tenant-Identifier": "default"},
json={
"creditAccountId": 4,
"creditAccountType": 4,
"dateFormat": "dd MMMM yyyy",
"debitAccountId": 4,
"debitAccountType": 2,
"locale": "en",
"name": "tax component 1",
"percentage": 10,
"startDate": "11 April 2016"
},
)
print(response.json())
const response = await fetch("http://localhost:8080/lokta-lms/api/v1/taxes/component", {
method: "POST",
headers: {
Authorization: "Basic " + Buffer.from("{username}:{password}").toString("base64"),
"Tenant-Identifier": "default",
"Content-Type": "application/json",
},
body: JSON.stringify({
"creditAccountId": 4,
"creditAccountType": 4,
"dateFormat": "dd MMMM yyyy",
"debitAccountId": 4,
"debitAccountType": 2,
"locale": "en",
"name": "tax component 1",
"percentage": 10,
"startDate": "11 April 2016"
}),
});
console.log(await response.json());
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("http://localhost:8080/lokta-lms/api/v1/taxes/component"))
.header("Authorization", "Basic "
+ Base64.getEncoder().encodeToString("{username}:{password}".getBytes()))
.header("Tenant-Identifier", "default")
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"creditAccountId": 4,
"creditAccountType": 4,
"dateFormat": "dd MMMM yyyy",
"debitAccountId": 4,
"debitAccountType": 2,
"locale": "en",
"name": "tax component 1",
"percentage": 10,
"startDate": "11 April 2016"
}
"""))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
payload := strings.NewReader(`{
"creditAccountId": 4,
"creditAccountType": 4,
"dateFormat": "dd MMMM yyyy",
"debitAccountId": 4,
"debitAccountType": 2,
"locale": "en",
"name": "tax component 1",
"percentage": 10,
"startDate": "11 April 2016"
}`)
req, _ := http.NewRequest("POST", "http://localhost:8080/lokta-lms/api/v1/taxes/component", payload)
req.SetBasicAuth("{username}", "{password}")
req.Header.Set("Tenant-Identifier", "default")
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
fmt.Println(string(data))