Champs personnalisés
Lire les champs propres à une organisation, et en écrire les valeurs.
Une organisation ajoute ses propres champs à ses fiches : un numéro d'adhérent sur un contact, un secteur sur une société… Chaque fiche porte la définition de ses champs et leurs valeurs.
Lire
GET https://staging-api.docage.com/Contacts/9b2d7a46-3c1e-4f0a-8b5d-1a2b3c4d5e6f
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9…curl "https://staging-api.docage.com/Contacts/9b2d7a46-3c1e-4f0a-8b5d-1a2b3c4d5e6f" \
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9…"using HttpClient client = new();
using HttpRequestMessage request = new(HttpMethod.Get, "https://staging-api.docage.com/Contacts/9b2d7a46-3c1e-4f0a-8b5d-1a2b3c4d5e6f");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
using HttpResponseMessage response = await client.SendAsync(request);
string result = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
throw new HttpRequestException(result);const response = await fetch("https://staging-api.docage.com/Contacts/9b2d7a46-3c1e-4f0a-8b5d-1a2b3c4d5e6f", {
headers: {
Authorization: `Bearer ${token}`
}
});
const text = await response.text();
if (!response.ok) throw new Error(text);
const result = text ? JSON.parse(text) : null;CustomFields: la définition de chaque champ — son nom technique (Name), son libellé, son type, ses options.CustomFieldsUserData: les valeurs, une entrée par champ renseigné.
{
"CustomFieldsUserData": [
{ "Name": "NumeroAdherent", "UserData": ["A-1024"] },
{ "Name": "CentresInteret", "UserData": ["Vitrine", "Éclairage"] }
]
}UserData porte toujours la valeur en texte, une entrée par valeur choisie ; un nombre, une date ou un oui/non s'y lit aussi,
typé, dans Number, Date ou Boolean.
Écrire
À la création comme à la modification, envoyez les valeurs dans CustomFieldsUserData, par nom technique :
PUT https://staging-api.docage.com/Contacts/9b2d7a46-3c1e-4f0a-8b5d-1a2b3c4d5e6f
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9…
Content-Type: application/json
{
"CustomFieldsUserData": [
{ "Name": "NumeroAdherent", "UserData": ["A-2048"] }
]
}curl -X PUT "https://staging-api.docage.com/Contacts/9b2d7a46-3c1e-4f0a-8b5d-1a2b3c4d5e6f" \
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9…" \
-H "Content-Type: application/json" \
-d '{
"CustomFieldsUserData": [{"Name": "NumeroAdherent", "UserData": ["A-2048"]}]
}'using HttpClient client = new();
using HttpRequestMessage request = new(HttpMethod.Put, "https://staging-api.docage.com/Contacts/9b2d7a46-3c1e-4f0a-8b5d-1a2b3c4d5e6f");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", token);
request.Content = new StringContent("""
{
"CustomFieldsUserData": [
{
"Name": "NumeroAdherent",
"UserData": [
"A-2048"
]
}
]
}
""", Encoding.UTF8, "application/json");
using HttpResponseMessage response = await client.SendAsync(request);
string result = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
throw new HttpRequestException(result);const response = await fetch("https://staging-api.docage.com/Contacts/9b2d7a46-3c1e-4f0a-8b5d-1a2b3c4d5e6f", {
method: "PUT",
headers: {
Authorization: `Bearer ${token}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"CustomFieldsUserData": [{"Name": "NumeroAdherent", "UserData": ["A-2048"]}]
})
});
const text = await response.text();
if (!response.ok) throw new Error(text);
const result = text ? JSON.parse(text) : null;Seuls les champs nommés changent ; les autres gardent leur valeur. Un PUT peut aussi nommer un champ comme une propriété :
{ "NumeroAdherent": "A-2048" }.
Attention
Un CustomFieldsUserData dont toutes les valeurs sont vides efface toutes les valeurs de la fiche. Pour vider un seul
champ, envoyez-le avec une autre valeur renseignée, ou nommez-le comme une propriété.
Filtrer
Dans une liste, un champ personnalisé se désigne par CustomFields. suivi de son nom technique :
{ "Filter": { "PropertyName": "CustomFields.NumeroAdherent", "Comparison": "startswith", "Value": "A-" } }Voir Lire des listes.