Update a Country
Endpoint Overview
This API endpoint provides a detailed overview of the endpoint responsible for updating an existing country within the Resources module of the Juleb ERP.
name is still requiredThis endpoint reuses the same request body as Create a Country, so name
must still be included even when only updating other fields.
Endpoint Details
- Method: PATCH
- URL:
/api/v1/resources/res-country/{id}
Parameters
- Path Parameters:
id(string, required): The ID of the country to update.
- Query Parameters: None
Request Body
Same fields as Create a Country: name (required), code,
address_format, phone_code, name_position, vat_label.
{
"name": string,
"vat_label": string
}
Response
- 202 Accepted: Successfully updated the record.
- 400 Bad Request: Bad request.
- 401 Unauthorized: Unauthorized.
- 404 Not Found: Record with the provided ID not found.
Response Body
{
"data": {
...record fields
}
}
Example
Request
- NodeJS
- curl
- python
- java
const axios = require('axios');
const accountName = process.env.ACCOUNT_NAME;
const apiKey = process.env.API_KEY;
axios.patch(`https://${accountName}.juleb.com/api/v1/resources/res-country/193`, {
name: 'Saudi Arabia',
vat_label: 'TRN'
}, {
headers: {
accept: '*/*',
Authorization: `TOKEN`,
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error('Error:', error);
});
curl -X PATCH \
-H "accept: */*" \
-H "Authorization: ******" \
-H "Content-Type: application/json" \
-d '{
"name": "Saudi Arabia",
"vat_label": "TRN"
}' \
"https://$ACCOUNT_NAME.juleb.com/api/v1/resources/res-country/193"
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/resources/res-country/193'
headers = {
'accept': '*/*',
'Authorization': f'******',
'Content-Type': 'application/json'
}
data = {
'name': 'Saudi Arabia',
'vat_label': 'TRN'
}
response = requests.patch(url, headers=headers, json=data)
if response.status_code == 202:
print(response.json())
else:
print(f'Error: {response.status_code}', response.text)
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;
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 = "{"
+ "\"name\": \"Saudi Arabia\","
+ "\"vat_label\": \"TRN\""
+ "}";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(new URI("https://" + accountName + ".juleb.com/api/v1/resources/res-country/193"))
.header("accept", "*/*")
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString(json))
.build();
HttpResponse<String> response = client.send(request, BodyHandlers.ofString());
if (response.statusCode() == 202) {
System.out.println(response.body());
} else {
System.out.println("Error: " + response.statusCode() + ", " + response.body());
}
}
}
Response
{
"data": {
"id": 193,
"name": "Saudi Arabia",
"vat_label": "TRN"
}
}