Update CustomFields - m3ter Documentation
Update CustomFields
cURL
curl --request PUT \
--url https://api.m3ter.com/organizations/{orgId}/customfields \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"version": 6,
"organization": {
"Org Example 2": "Sample text 2.",
"Org Example 1": "Sample text 1."
},
"account": {},
"accountPlan": {
"New CF Test": "Test Value"
},
"meter": {},
"product": {
"Product CF Example": 42
},
"planTemplate": {},
"plan": {},
"aggregation": {},
"compoundAggregation": {}
}
'
Python Example
import requests
url = "https://api.m3ter.com/organizations/{orgId}/customfields"
payload = {
"version": 6,
"organization": {
"Org Example 2": "Sample text 2.",
"Org Example 1": "Sample text 1."
},
"account": {},
"accountPlan": { "New CF Test": "Test Value" },
"meter": {},
"product": { "Product CF Example": 42 },
"planTemplate": {},
"plan": {},
"aggregation": {},
"compoundAggregation": {}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)
JavaScript Example
const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
version: 6,
organization: {'Org Example 2': 'Sample text 2.', 'Org Example 1': 'Sample text 1.'},
account: {},
accountPlan: {'New CF Test': 'Test Value'},
meter: {},
product: {'Product CF Example': 42},
planTemplate: {},
plan: {},
aggregation: {},
compoundAggregation: {}
})
};
fetch('https://api.m3ter.com/organizations/{orgId}/customfields', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP Example
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.m3ter.com/organizations/{orgId}/customfields",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'version' => 6,
'organization' => [
'Org Example 2' => 'Sample text 2.',
'Org Example 1' => 'Sample text 1.'
],
'account' => [],
'accountPlan' => [
'New CF Test' => 'Test Value'
],
'meter' => [],
'product' => [
'Product CF Example' => 42
],
'planTemplate' => [],
'plan' => [],
'aggregation' => [],
'compoundAggregation' => []
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
Go Example
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.m3ter.com/organizations/{orgId}/customfields"
payload := strings.NewReader("{\n \"version\": 6,\n \"organization\": {\n \"Org Example 2\": \"Sample text 2.\",\n \"Org Example 1\": \"Sample text 1.\"\n },\n \"account\": {},\n \"accountPlan\": {\n \"New CF Test\": \"Test Value\"\n },\n \"meter\": {},\n \"product\": {\n \"Product CF Example\": 42\n },\n \"planTemplate\": {},\n \"plan\": {},\n \"aggregation\": {},\n \"compoundAggregation\": {}\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}
Response Example
{
"id": "81c49a54-dfcd-4da5-bbf3-d2885ec025dd",
"version": 4,
"organization": {
"Org Example 2": "Sample text 2.",
"Org Example 1": "Sample text."
},
"product": {
"Product CF Example": 42
},
"account": {},
"accountPlan": {
"New CF Test": "Test Value"
},
"meter": {},
"planTemplate": {},
"plan": {},
"aggregation": {},
"compoundAggregation": {}
}
Error Response
{
"message": "<string>"
}
Authorization
Authorization header is required.
Path Parameters
orgId: UUID of the Organization, required.