0

I wanted to ask about strategies, and how can i send data to server, which accepts Json data.

So server wants data in this format

www.myapi//moviesCollector?report={"movies":[{"id":20,"movie_cat":566}]}

In my controller i have this data (id, movie_cat), but i have no idea how to start.

Thank You for help. I'm using cakephp3, but maybe logic is similar to 2.x ?

Marek Brzeziński
  • 325
  • 1
  • 3
  • 13
  • It's not clear what you're asking but "server wants data in this format" is not json, it's a url argument that is json (are you defining that, as I've never seen any api expect url arguments to be json strings..? That's both odd and cumbersome/fragile) – AD7six Jul 24 '15 at 13:06
  • Yes, all true, and also true, that server wants data in this format. This API is used by Android and IOS devices, maybe that is the reason, why this looks like that... – Marek Brzeziński Jul 24 '15 at 13:14
  • Ok, right now, if this is odd, i want to ask about strategies, how send data to API using cakephp , if example Api url may be www.myapi/11/333/ – Marek Brzeziński Jul 24 '15 at 13:28
  • GET arguments are normally like any other url [here's an example](http://platform.seatgeek.com/#responses) of an api that returns json. For POST/PUT/PATCH/ETC. requests, the _request body_ might be json encoded - _that_ would be normal for an api (and [typical for mobile devices to expect to use an api in that way](http://stackoverflow.com/questions/6533234/how-to-make-httppost-call-with-json-encoded-body)). – AD7six Jul 24 '15 at 13:32
  • Well, i have used Cakephp3 Client() and then post(). It works, but some part of json causes error: Unterminated string at character 75 (this part of JSON -> "downloaded":"2015-07-24 12:11:05"), how can i escape this ? – Marek Brzeziński Jul 27 '15 at 07:28

0 Answers0