Fetch API
POST /rest/fetch
Execute a query.
Request
Header | Value | Description |
---|---|---|
Content-Type | text/plain | The content type. |
X-CSRF-Token | The value from the one.erp.csrf.token cookie. | CSRF protection token. |
The payload is the fetch query:
FETCH entity (key, name)
Response
200 Ok
The operation was successful. The resultset:
[{
"column1": "value",
"column2": 11
},
{
"column1": "value1",
"column2": 12
}]
400 Bad Request
There was an error deserializing the JSON message.
{
"detail": "error detail"
}
401 Unauthorized
The operation is not authorized.
Check if the authentication cookie is set or valid or a valid username and password are set in the URL.
500 Internal Error
All errors except for JSON message deserialization errors.
{
"detail": "error detail"
}
cURL Example
Query some rows
Given the following cURL request:
curl --header "X-API-Key: e3097afe-1528-4fdb-a816-0d3724a8f318" \
--header "Content-Type: text/plain" \
--url "https://devdev17.oneerp.ro/rest/fetch" \
-X POST \
-d "FETCH entity (key, name) LIMIT 2"
The server will return the following response:
[
{
"name": "customization_set",
"key": 1
},
{
"name": "customization_set_property",
"key": 2
}
]
POST /rest/fetch/parse
Parse a FETCH query to a JSON representation.
FETCH JSON representation
{
"fetch": {
"entities": [{
"entity": "",
"properties": [{
"property": "",
"aggregate": "",
"alias": "",
"groupBy": false
}],
"filter": [{
"type": "And|Or",
"conditions": [{
"property": "",
"operator": "",
"value": ""
}],
"filter": {
"type": "And|Or",
"conditions": [{
"property": "",
"operator": "",
"value": ""
}],
"filter": ...
}
}],
"links": [{
"entity": "",
"from": "",
"to": "",
"filter": [],
"links": [],
"orderBy": [
{
"name": "",
"asc": false
}
],
"offset": 0,
"limit": 0,
}],
"orderBy": [{
"name": "",
"asc": false
}],
"offset": 0,
"limit": 0,
}]
}
}
Request
Header | Value | Description |
---|---|---|
Content-Type | text/plain | The content type. |
X-CSRF-Token | The value from the one.erp.csrf.token cookie. | CSRF protection token. |
The payload is the fetch query:
FETCH entity (key, name)
Response
200 Ok
The operation was successful. The resultset:
[{
"column1": "value",
"column2": 11
},
{
"column1": "value1",
"column2": 12
}]
400 Bad Request
There was an error deserializing the JSON message.
{
"detail": "error detail"
}
401 Unauthorized
The operation is not authorized.
Check if the authentication cookie is set or valid or a valid username and password are set in the URL.
500 Internal Error
All errors except for JSON message deserialization errors.
{
"detail": "error detail"
}
cURL Example
Parse a fetch
Given the following cURL request:
curl --header "X-API-Key: e3097afe-1528-4fdb-a816-0d3724a8f318" \
--header "Content-Type: text/plain" \
--url "https://devdev17.oneerp.ro/rest/fetch/parse" \
-X POST \
-d "FETCH customization_set (key, name) { customization_set_property TO customization_set (name AS propertyName) } LIMIT 2"
The server will return the following response:
{"fetch": [{
"limit": 2,
"links": [{
"to": "id_customization_set",
"entity": "customization_set_property",
"properties": [{
"property": "name",
"alias": "propertyName"
}]
}],
"entity": "customization_set",
"properties": [
{"property": "key"},
{"property": "name"}
]
}]}
POST /rest/metadata/fetch
Retrieve metadata about the fetch results.