Is valid data for custom API¶
Runs the reqBodySchema or reqQueryParametersSchema of a custom API on some data and answers the errors the API would refuse it with, without running the API.
| Method | POST |
| URL | /api/system-api/admin/is-valid-data-for-custom-api : admin is the user path of your account |
| Body | { name, type, data } or an array of them |
| Answer | data : an array of errors (empty when valid), or an array of arrays |
| From code | g.sys.system.isValidDataForCustomAPI |
The custom API settings¶
The call¶
Answer
{
"success": true,
"statusCode": 200,
"data": [
{ "type": "required", "field": "first_name", "message": "Please provide valid 'first_name' field with type 'string'.", "code": 400 },
{ "type": "min", "field": "phone", "message": "Please provide minimum '5' for 'phone' field.", "code": 400 }
]
}
| Key | Meaning |
|---|---|
name |
The name of the custom API. |
type |
BODY for reqBodySchema, QUERY_PARAMS for reqQueryParametersSchema. |
data |
The body or the query params to check. |
From code¶
An unknown custom API answers 400 : Unable to find custom API with name ….
Access, headers and errors¶
- Over HTTP, a system API answers only once its settings open it :
TOKEN_ACCESS(the token of an API user whose group grants this system API) orIS_PUBLIC. Without settings it isNO_ACCESS: only your code (g.sys) and the admin panel reach it. - The settings can also keep the answer in the cache, or ask for the token of a person (
authProviders). Pre and post hooks run around it, as around any API. - It takes the request headers and answers the envelope.
401: no valid token, or the API isNO_ACCESS.403: no group grants it.400: the body is wrong, and the message names the key.
Related : All APIs · System API settings · System APIs from code