# Custom HTTP Socket Datasource \> Create with related data

**URL:** <https://discourse.cakephp.org/t/custom-http-socket-datasource-create-with-related-data/1528>\
**Category:** Need Help\
**Created:** [November 13, 2016, 1:52pm UTC](https://discourse.cakephp.org/t/custom-http-socket-datasource-create-with-related-data/1528 "2016-11-13T13:52:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phpMagpie](https://avatars.discourse-cdn.com/v4/letter/p/d26b3c/32.png) [@phpMagpie](https://discourse.cakephp.org/u/phpMagpie)\
**Post date:** [November 13, 2016, 1:52pm UTC](https://discourse.cakephp.org/t/custom-http-socket-datasource-create-with-related-data/1528/1 "2016-11-13T13:52:08Z")

</div>

Hi all,

I’m working on a HTTP Socket Datasource for an API integration and want to POST a new resource including related resource data.

Problem is the related resource data is being stripped out of the request as it’s not in the schema declarations.

Any tips from you guys on how I submit a POST request with a JSON data string that matches the following structure would be greatly appreciated:

```
{
  "addresses": [
      {
        "city": "Dallas",
        "country": "US",
        "state":-"TX",
        ...
      }
  ],
  "first_name": "Don",
  "last_name": "Parsley",
  ...
}
```

---

<div class="post-metadata">

**Author:** ![Andrej](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/andrej/32/446_2.png) [@Andrej](https://discourse.cakephp.org/u/Andrej)\
**Post date:** [November 19, 2016, 11:26am UTC](https://discourse.cakephp.org/t/custom-http-socket-datasource-create-with-related-data/1528/2 "2016-11-19T11:26:06Z")

</div>

Hi phpMagpie,

not sure I correctly understand what do you mean, but what about this example here:  
[http://book.cakephp.org/3.0/en/core-libraries/httpclient.html#sending-request-bodies](http://book.cakephp.org/3.0/en/core-libraries/httpclient.html#sending-request-bodies)

---

<div class="post-metadata">

**Author:** ![phpMagpie](https://avatars.discourse-cdn.com/v4/letter/p/d26b3c/32.png) [@phpMagpie](https://discourse.cakephp.org/u/phpMagpie)\
**Post date:** [November 24, 2016, 2:22pm UTC](https://discourse.cakephp.org/t/custom-http-socket-datasource-create-with-related-data/1528/3 "2016-11-24T14:22:01Z")

</div>

Andrej,

Thanks for responding … I’m using HttpSocket in CakePHP 2.x unfortunately, my bad for not being more clear about my environment.

The problem is when I pass in a data array() to `Model::save()` is it checked against the model’s schema declaration and if values in your data array are not in the schema, they are stripped from the request.

I have found that I can then intercept the data array and re-inject my extra data before calling `$this->_request('POST', $url, json_encode($data))`, but this feels a bit hacky and wondered how I could get CakePHP’s models setup to accept my original data array.

Thanks, Paul.
