Skip to content

Commit 9fe1b85

Browse files
committed
Send data as json
1 parent b22ea62 commit 9fe1b85

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

lib/ApiClient/TicketparkApiClient.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function get($path, $parameters = array(), $headers = array())
208208
*/
209209
public function post($path, $content = '', $headers = array())
210210
{
211-
return $this->getBrowser()->post(self::ROOT_URL . $path, $this->getDefaultHeaders($headers), $content);
211+
return $this->getBrowser()->post(self::ROOT_URL . $path, $this->getDefaultHeaders($headers), json_encode($content));
212212
}
213213

214214
/**
@@ -238,7 +238,7 @@ public function head($path, $parameters = array(), $headers = array())
238238
*/
239239
public function patch($path, $content = '', $headers = array())
240240
{
241-
return $this->getBrowser()->patch(self::ROOT_URL . $path, $this->getDefaultHeaders($headers), $content);
241+
return $this->getBrowser()->patch(self::ROOT_URL . $path, $this->getDefaultHeaders($headers), json_encode($content));
242242
}
243243

244244
/**
@@ -251,7 +251,7 @@ public function patch($path, $content = '', $headers = array())
251251
*/
252252
public function put($path, $content = '', $headers = array())
253253
{
254-
return $this->getBrowser()->put(self::ROOT_URL . $path, $this->getDefaultHeaders($headers), $content);
254+
return $this->getBrowser()->put(self::ROOT_URL . $path, $this->getDefaultHeaders($headers), json_encode($content));
255255
}
256256

257257
/**
@@ -310,7 +310,7 @@ public function generateTokens()
310310
protected function getDefaultHeaders($customHeaders = array())
311311
{
312312
$headers = array(
313-
'Content-Type' => 'application/x-www-form-urlencoded',
313+
'Content-Type' => 'application/json',
314314
'Accept' => 'application/json',
315315
'Authorization' => 'Bearer ' . $this->getValidAccessToken()
316316
);

test/ApiClient/TicketparkApiClientTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function testGet()
194194
'with' => array(
195195
$this->equalTo('https://api.ticketpark.ch/shows?a=1&b=2&c%5Bd%5D=3'),
196196
$this->equalTo(array(
197-
'Content-Type' => 'application/x-www-form-urlencoded',
197+
'Content-Type' => 'application/json',
198198
'Accept' => 'application/json',
199199
'Authorization' => 'Bearer myAccessToken',
200200
'CustomHeader' => 'foo'
@@ -220,7 +220,7 @@ public function testHead()
220220
'with' => array(
221221
$this->equalTo('https://api.ticketpark.ch/shows?a=1&b=2&c%5Bd%5D=3'),
222222
$this->equalTo(array(
223-
'Content-Type' => 'application/x-www-form-urlencoded',
223+
'Content-Type' => 'application/json',
224224
'Accept' => 'application/json',
225225
'Authorization' => 'Bearer myAccessToken',
226226
'CustomHeader' => 'foo'
@@ -246,12 +246,12 @@ public function testPatch()
246246
'with' => array(
247247
$this->equalTo('https://api.ticketpark.ch/shows/foo'),
248248
$this->equalTo(array(
249-
'Content-Type' => 'application/x-www-form-urlencoded',
249+
'Content-Type' => 'application/json',
250250
'Accept' => 'application/json',
251251
'Authorization' => 'Bearer myAccessToken',
252252
'CustomHeader' => 'foo'
253253
)),
254-
$this->equalTo('content')
254+
$this->equalTo('"content"')
255255
),
256256
'response' => array(
257257
'status' => 200,
@@ -273,12 +273,12 @@ public function testPost()
273273
'with' => array(
274274
$this->equalTo('https://api.ticketpark.ch/shows/foo'),
275275
$this->equalTo(array(
276-
'Content-Type' => 'application/x-www-form-urlencoded',
276+
'Content-Type' => 'application/json',
277277
'Accept' => 'application/json',
278278
'Authorization' => 'Bearer myAccessToken',
279279
'CustomHeader' => 'foo'
280280
)),
281-
$this->equalTo('content')
281+
$this->equalTo('"content"')
282282
),
283283
'response' => array(
284284
'status' => 200,
@@ -300,12 +300,12 @@ public function testPut()
300300
'with' => array(
301301
$this->equalTo('https://api.ticketpark.ch/shows/foo'),
302302
$this->equalTo(array(
303-
'Content-Type' => 'application/x-www-form-urlencoded',
303+
'Content-Type' => 'application/json',
304304
'Accept' => 'application/json',
305305
'Authorization' => 'Bearer myAccessToken',
306306
'CustomHeader' => 'foo'
307307
)),
308-
$this->equalTo('content')
308+
$this->equalTo('"content"')
309309
),
310310
'response' => array(
311311
'status' => 200,
@@ -327,7 +327,7 @@ public function testDelete()
327327
'with' => array(
328328
$this->equalTo('https://api.ticketpark.ch/shows/foo'),
329329
$this->equalTo(array(
330-
'Content-Type' => 'application/x-www-form-urlencoded',
330+
'Content-Type' => 'application/json',
331331
'Accept' => 'application/json',
332332
'Authorization' => 'Bearer myAccessToken',
333333
'CustomHeader' => 'foo'

0 commit comments

Comments
 (0)