-1

I search SO for similar questions, but even though the title was same, I was unable to find an answer so I am reposting.

I have a REST endpoint which till now was a POST call even though it was only retrieving data. I am trying to convert this to a GET call. The payload is a JSON for the POST method. I know I can convert the JSON into URL parameters and pass it. However I wanted to check if I can pass this JSON as a GET request itself.

Is there any way in PHP to pass JSON in a GET request?

Undefined Variable
  • 3,670
  • 6
  • 34
  • 63
  • 4
    Possible duplicate of [HTTP GET with request body](http://stackoverflow.com/questions/978061/http-get-with-request-body) – Matt S Mar 16 '16 at 15:27

1 Answers1

0

It's a messy proposition but you should be able to urlencode your JSON and pass it that way

$data = ['some' => 'value'];
echo urlencode(json_encode($data));
Machavity
  • 28,730
  • 25
  • 78
  • 91