Instead of making a call to an end-point from browser, we can use cURL to do same thing in command line so chekcout example below to see how it is done.


Normal browser GET request


If you call http://football.local/app_dev.php/backend/user?page=1&limit=2 from the browser, you would get response below.


Cache-Control → no-cache
Connection → Keep-Alive
Content-Length → 217
Content-Type → application/json
Date → Sat, 27 Jun 2015 18:34:58 GMT
Keep-Alive → timeout=5, max=100
Server → Apache/2.4.10 (Unix) PHP/5.6.9
X-Debug-Token → 946971
X-Debug-Token-Link → /app_dev.php/_profiler/946971
X-Powered-By → PHP/5.6.9

{
"users": [
{
"id": 1,
"username": "inanzzz",
"password": "09cd68a2a77b22a312dded612dd0d9988685189f"
},
{
"id": 2,
"username": "robertdeniro",
"password": "09cd68a2a77b22a312dded612dd0d9988685189f"
}
],
"page": "1",
"limit": "2",
"total": 6
}

cURL versions of same request


Version 1


Inanzzz-MBP:football inanzzz$ curl -v -X GET http://football.local/app_dev.php/backend/user?page=1&limit=2
[3] 26544
[2] Done curl -v -X GET 127.0.0.1/app_dev.php/backend/user?page=1
Inanzzz-MBP:football inanzzz$ * Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to football.local (127.0.0.1) port 80 (#0)
> GET /app_dev.php/backend/user?page=1 HTTP/1.1
> User-Agent: curl/7.37.1
> Host: football.local
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Sat, 27 Jun 2015 18:49:57 GMT
* Server Apache/2.4.10 (Unix) PHP/5.6.9 is not blacklisted
< Server: Apache/2.4.10 (Unix) PHP/5.6.9
< X-Powered-By: PHP/5.6.9
< Cache-Control: no-cache
< X-Debug-Token: 99d00d
< X-Debug-Token-Link: /app_dev.php/_profiler/99d00d
< Content-Length: 215
< Content-Type: application/json
<
* Connection #0 to host football.local left intact
{"users":[{"id":1,"username":"inanzzz","password":"09cd68a2a77b22a312dded612dd0d9988685189f"},{"id":2,"username":"robertdeniro","password":"09cd68a2a77b22a312dded612dd0d9988685189f"}],"page":"1","limit":2,"total":6}

Version 2


Inanzzz-MBP:football inanzzz$ curl -v -X GET -H "application/json" -d '{"page":"1","limit":"2"}' http://football.local/app_dev.php/backend/user
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to football.local (127.0.0.1) port 80 (#0)
> GET /app_dev.php/backend/user HTTP/1.1
> User-Agent: curl/7.37.1
> Host: football.local
> Accept: */*
> Content-Length: 24
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 24 out of 24 bytes
< HTTP/1.1 200 OK
< Date: Sat, 27 Jun 2015 18:52:34 GMT
* Server Apache/2.4.10 (Unix) PHP/5.6.9 is not blacklisted
< Server: Apache/2.4.10 (Unix) PHP/5.6.9
< X-Powered-By: PHP/5.6.9
< Cache-Control: no-cache
< X-Debug-Token: fd3a65
< X-Debug-Token-Link: /app_dev.php/_profiler/fd3a65
< Content-Length: 213
< Content-Type: application/json
<
* Connection #0 to host football.local left intact
{"users":[{"id":1,"username":"inanzzz","password":"09cd68a2a77b22a312dded612dd0d9988685189f"},{"id":2,"username":"robertdeniro","password":"09cd68a2a77b22a312dded612dd0d9988685189f"}],"page":1,"limit":2,"total":6}

Normal browser POST request


If you POST {"username": "inanzzz", "password": "mypassword"} as request payload to http://football.local/app_dev.php/backend/user from the browser, you would get response below.


Cache-Control → no-cache
Connection → Keep-Alive
Content-Length → 13
Content-Type → application/json
Date → Sat, 27 Jun 2015 19:00:49 GMT
Keep-Alive → timeout=5, max=100
Server → Apache/2.4.10 (Unix) PHP/5.6.9
X-Debug-Token → 514fe0
X-Debug-Token-Link → /app_dev.php/_profiler/514fe0
X-Powered-By → PHP/5.6.9

"USER create"

cURL versions of same request


Inanzzz-MBP:football inanzzz$ curl -v -X POST -H "application/json" -d '{"username": "inanzzz", "password": "mypassword"}' http://football.local/app_dev.php/backend/user 
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to football.local (127.0.0.1) port 80 (#0)
> POST /app_dev.php/backend/user HTTP/1.1
> User-Agent: curl/7.37.1
> Host: football.local
> Accept: */*
> Content-Length: 47
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 47 out of 47 bytes
< HTTP/1.1 200 OK
< Date: Sat, 27 Jun 2015 19:02:41 GMT
* Server Apache/2.4.10 (Unix) PHP/5.6.9 is not blacklisted
< Server: Apache/2.4.10 (Unix) PHP/5.6.9
< X-Powered-By: PHP/5.6.9
< Cache-Control: no-cache
< X-Debug-Token: 0d3815
< X-Debug-Token-Link: /app_dev.php/_profiler/0d3815
< Content-Length: 13
< Content-Type: application/json
<
* Connection #0 to host football.local left intact
"USER create"