0

I am using RESTClient for firefox addon to test REST API, i set some headers that's working fine if i set request body and method to GET , i couldn't access data via my PHP application, but headers available

**Request headers**   
   Content-Type : application/json

**Request Body**  

   [
   {
    "data1" : "value1",
    "data2" : "value2",
    "data3" : 1
    }
   ]

How do i set Request body correctly?

Dr. Rajesh Rolen
  • 13,143
  • 39
  • 98
  • 173
Suriyan Suresh
  • 2,872
  • 13
  • 47
  • 80

1 Answers1

5

Set a body to GET requests is a "nonsense" because GET means retrieve some information and the body of a request is used to send data.

It is precisely from this point of view that web servers, most of the time, ignore the body of a GET request, which could explain why you can't get your data from your PHP script.

If the purpose of your request is to create or update a resource you should consider using a POST or PUT to be REST.

There is already a topic opened with almost the same question here : HTTP GET with request body

Community
  • 1
  • 1
basgys
  • 4,025
  • 24
  • 39