Skip to main content
Version: 10.x


Form content types (W3C)

By default, Apiato is configured to encode simple text/ASCII data x-www-form-urlencoded. However, it does support other types as well.

ASCII payload

To tell the web server that you are posting simple text/ASCII payload (name=John+Doe&age=18), you need to include Content-Type : x-www-form-urlencoded in the request header.

JSON payload

To tell the web server that you are posting JSON-formatted payload ({name : 'John Doe', age: 18}), you need to include Content-Type = application/json in the request header.

(you may wish return Json data in this case as well, you can do so by changing the response serializer from DataArraySerializer to JsonApiSerializer, more about that in the response page).

HTTP Request Headers

HeaderValue SampleWhen to send it
Acceptapplication/jsonMUST be sent with every endpoint.
Content-Typeapplication/x-www-form-urlencodedMUST be sent when passing Data.
AuthorizationBearer {Access-Token-Here}MUST be sent whenever the endpoint requires (Authenticated User).
If-None-Match811b22676b6a4a0489c920073c0df914MAY be sent to indicate a specific ETag of an prior Request to this Endpoint. If both ETags match (i.e., are the same) a HTTP 304 (not modified) is returned.

Heads Up!

Normally you should include the Accept : application/json HTTP header when you call a JSON API. However, in Apiato you can force your users to send application/json by setting 'force-accept-header' => true, in app/Ship/Configs/apiato.php or allow them to skip it completely by setting the 'force-accept-header' => false,. By default this flag is set to false.

Calling Endpoints

Calling unprotected endpoint example:

curl -X POST -H "Accept: application/json" -H "Content-Type: application/x-www-form-urlencoded; -F "email=[email protected]" -F "password=admin" -F "=" "http://api.domain.test/v2/register"

Calling protected endpoint (passing Bearer Token) example:

curl -X GET -H "Accept: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." -H "http://api.domain.test/v1/users"