An entity is a custom data table defined as User Entity on magnews. With rest API you can:
Note
Use in {entity} the name of the user entity and not the name of the data table.
Use in {entity} the name of the user entity and not the name of the data table.
Create/Update/Upsert a record in an entity table
POST https://apiserver/ws/rest/api/v19/entities/{entity}/data
Result: an existing record is updated, if a record does not exist, then it is created. Lookup is performed using fields in the post body (table primary or user primary key fields)
Request body example:
{ "options": { "operationtype": "upsert" }, "fields": { "myuserprimarykey": 1234, "mystringfield": "hello", "myint": 1, "mynumber": 10.05, "mybool": true, "mydatetime": "24/06/2021 10:05", "mydate": "24/06/2021" } }
Response example:
{ "primarykey": { "myautoincprimarykey":1 }, "fields": { "myuserprimarykey": 1234, "mystringfield": "hello", "myint": 1, "mynumber": 10.05, "mybool": true, "mydatetime": "24/06/2021 10:05", "mydate": "24/06/2021" } }
Post Body options:
Option | Type | Default Value | Description |
---|---|---|---|
operationtype | String | upsert | Type of operation to perform. Possibile values are: update or insert or upsert |
Post Body fields format:
Column data type | Entity field type | Example | Description |
---|---|---|---|
Text/Long text | "my string value" | Double quoted string | |
Integer (1 byte) | Integer | 1 | Int number |
Integer (1 byte) | Checkbox | true | Boolean value true/false |
Integer (4 or 8 bytes) | 10 | Int number | |
Decimal number | "10.5" or "10,5" | Quoted string formatted according current user International settings (Real numbers format) | |
Date | "24/06/2017" | A quoted string formatted according current user International settings (Date format and Time zone) | |
Date and time | "24/06/2017 10:17" | A quoted string formatted according current user International settings (Date - time format and Time zone) |
Read a record of an entity table
GET https://apiserver/ws/rest/api/v19/entities/{entity}/data?myuserprimarykey=1234
Result: an existing record. Lookup is performed using fields in the post body (table primary or user primary key fields)
Response example:
{ "primarykey": { "myautoincprimarykey":1 }, "fields": { "myuserprimarykey": 1234, "mystringfield": "hello", "myint": 1, "mynumber": 10.05, "mybool": true, "mydatetime": "24/06/2021 10:05", "mydate": "24/06/2021" } }