Create New Config
Endpoint Overview
This API endpoint provides a detailed overview of the endpoint responsible for creating a config within the POS module of the Juleb ERP.
Endpoint Details
- Method: POST
- URL:
/api/v1/pos/config
Parameters
-
Path Parameters: None
-
Query Parameters: None
-
Request Body:
{
"name": string,
"allow_out_of_stock":boolean,
"company_id": integer
}
Response
- 201 OK: Successfully created the record.
- 400 Bad Request: Invalid parameters.
- 401 Unauthorized: Authentication required.
Response Body
Id of the created record.
Example
Request
- NodeJS
- curl
- python
- java
curl -X POST \
-H "accept: */*" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"companyId": 37,
"name": "api_test",
"allow_out_of_stock":false,
}' \
"https://$ACCOUNT_NAME.juleb.com/api/v1/pos/config"
const axios = require('axios');
const accountName = process.env.ACCOUNT_NAME;
const apiKey = process.env.API_KEY;
axios
.post(
`https://${accountName}.juleb.com/api/v1/pos/config`,
{
companyId: 37,
name: 'api_test',
allow_out_of_stock: false,
},
{
headers: {
accept: '*/*',
Authorization: `Bearer ${apiKey}`,
'Content-Type': 'application/json',
},
}
)
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error('Error:', error);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpResponse.BodyHandlers;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;
public class Main {
public static void main(String[] args) throws Exception {
String accountName = System.getenv("ACCOUNT_NAME");
String apiKey = System.getenv("API_KEY");
String json = "{\"companyId\": 37, \"name\": \"api_test\",\"allow_out_of_stock\":false}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://" + accountName + ".juleb.com/api/v1/pos/config"))
.header("accept", "*/*")
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
if (response.statusCode() == 200) {
System.out.println(response.body());
} else {
System.out.println("Error: " + response.statusCode() + ", " + response.body());
}
}
}
import os
import requests
account_name = os.getenv('ACCOUNT_NAME')
api_key = os.getenv('API_KEY')
url = f'https://{account_name}.juleb.com/api/v1/pos/config'
headers = {
'accept': '*/*',
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
data = {
"companyId": 37,
"name": "api_test",
"allow_out_of_stock":false,
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print(response.json())
else:
print(f'Error: {response.status_code}', response.text)
Response
375