XF 2.1 REST API: how to read a json object posted in the body

Cylon

Member
Hi!

I'm working on an addon that hast a custom POST API endpoint. My intention is to send a JSON object as payload in the body. But I don't find a way to read id on the XF side.

Is really application/x-www-form-urlencoded the only way to post things to the API Endpoints? I'm posting a json object with a lot of fields, and posting each field as a parameter, and then receiving on the endpoint side each parameter and constructing again the object is a lot of boilerplate code...

Thank you for your attention
 
You have to POST the data as part of a form, but a form field can contain JSON. You can read it using $this->filterFormJson($filters, 'name') (where $filters is an array that maps proper filters for each key).
 
Top Bottom