What this is about
Every request that returns data carries a response list. It tells CDMS which fields should be in the response. This applies to read, query, create, update, patch and rollback.
{
"response": ["id", "firstname", "+", { "field": "company", "response": ["companyname"] }],
"exclude": ["internalNote"]
}
The three kinds of entries
An entry in response is either a text or an object:
flowchart TB
E["Entry in response"] --> T{"Text or object?"}
T -->|"Text without + and *"| F["Field name<br/>exactly this simple field"]
T -->|"Text with + or *"| W["Wildcard<br/>many fields at once"]
T -->|"Object { field, response }"| O["Expand a reference<br/>with its own field selection"]
| Entry | Example | returns |
|---|---|---|
| Field name | "firstname" | exactly this simple field |
| Wildcard | "+", "*", "+name", "depart*" | all matching fields, see Wildcards |
| Object | { "field": "company", "response": ["companyname"] } | the reference company with its own field selection |
Next to response there is also the exclude list. It removes fields again that a wildcard added.
The object in detail
An object expands a reference. It has up to four keys:
| Key | Required | Meaning |
|---|---|---|
field | yes | name of the reference in the model, e.g. company or employees |
response | yes | field selection for the referenced object, with the same three kinds of entries |
exclude | no | as above, but only for this level |
parameter | no | lists only: filter, sorting, page size for the entries of the list |
Because response inside the object may contain objects again, you can nest as deep as you like. How that works is described under Expanding references and lists.
Example on the employee model
The same model as on the other pages of this chapter: employee with firstname, lastname and the references company and department.
POST /api/rest/hr/employee/read/7f3…
{
"response": [
"firstname",
"+name",
{ "field": "company", "response": ["companyname"] }
]
}{
"data": {
"id": "7f3…",
"firstname": "Daniel",
"lastname": "Mertins",
"company": { "id": "a1…", "companyname": "Codamic AG" },
"department": null
},
"meta": { "error": false }
}firstname appears twice, once as a name and once through +name. That does no harm, CDMS reads every field only once.
What CDMS does with unusual entries
When: The body is {} or contains only exclude.
-
1Client→CDMSsends
POST /read/{id}withoutresponse -
2CDMS→Client400
InvalidQueryDefinitionExceptionwithmessageKeyresponse
Result: 400. The same applies to an object { "field": … } without its own response.
When: { "response": [] }
An empty list is allowed. CDMS then reads only what it always reads: id, _createdOn and _updatedOn.
Result: 200 with the system fields, everything else null. Handy when you only want to know whether the object exists and you may see it.
When: You write "fristname" instead of "firstname", or the field does not exist in this model.
-
1CDMSfinds no column for the name
-
2CDMSleaves the entry out, without an error
-
3CDMS→Clientreturns all other fields
Result: 200. The misspelled field is simply missing, the correct one is null.
When: { "field": "firma", "response": ["+"] }, but the reference is called company.
CDMS does not find firma in the model and skips the whole object.
Result: 200 without this reference.
When: { "field": "firstname", "response": ["+"] }
firstname is not a reference and cannot be expanded. CDMS skips the object.
Result: 200, and firstname is not returned. Name it as text.
When: The response reaches into company, the user lacks company-read.
-
1CDMSchecks the read role of
companywhile expanding -
2CDMS→Client403
missing-permission|company-read
Result: 403 for the whole request, not just for the reference.
Decision table
| Entry | exists in the model | read role of the target model | Result |
|---|---|---|---|
response missing | – | – | 400 response |
| Field name | yes | – | field is returned |
| Field name | no | – | silently left out, 200 |
| Wildcard | – | – | all matching fields, no match is 200 too |
| Object on a reference | yes | yes | reference with its own field selection |
| Object on a reference | yes | no | 403 missing-permission|<role> |
| Object on a reference | no | – | silently skipped, 200 |
| Object on a simple field | yes | – | silently skipped, 200 |
Permissions: per model and per relation
CDMS decides whether you may read something per model and per relation. Whoever may read employee may read the simple fields of employee, unless a field carries a read role of its own: then + leaves it out without this role, and requesting it by name results in 403. See Protected values. A role only comes into play when the response reaches into another model: then you need its read role or a role on the relation itself. See Model roles and Permissions on relations.
The tables above describe the default, strict mode. Without it, a single reference without the role is silently null; the other cases still fail, only with a different status or key. See Strict mode.