In a v2 October project, I am using the October\Rain\Network\HTTP
class to post data to an external API.
The data are directly extracted using the method getAttributes()
on my model which returned an array.
Some value are null, and the HTTP
class do not convert them properly in a json null value, but leave the value empty which cause a validation error on the external API.
here is some of my code.
$data = $model->getAttributes();
$result = Http::post($endpoint, function ($http) use ($data) {
$http->data($data);
});
$data
looks like this
[requestData] => Array
(
[id] => 1
[name] => ISO/TS 16949ss
[slug] => isots-16949
[description] => ISO/TS 16949
[is_enabled] => 1
[parent_id] =>
[sort_order] => 1
)
where parent_id
should be the value null
instead of being empty.
any idea how to get around that ?
or any way to send a raw body json query? I am thinking to override this HTTP class myself to give the capacity to send raw body request data but not sure what do to.