# Create Meeting API returns GET request - Guzzle / PHP

**URL:** <https://devforum.zoom.us/t/create-meeting-api-returns-get-request-guzzle-php/17222>\
**Category:** API and Webhooks\
**Created:** [May 12, 2020, 12:10pm UTC](https://devforum.zoom.us/t/create-meeting-api-returns-get-request-guzzle-php/17222 "2020-05-12T12:10:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![afletcher53](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/afletcher53/32/7784_2.png) [@afletcher53](https://devforum.zoom.us/u/afletcher53)\
**Post date:** [May 12, 2020, 12:10pm UTC](https://devforum.zoom.us/t/create-meeting-api-returns-get-request-guzzle-php/17222/1 "2020-05-12T12:10:03Z")

</div>

**Description**  
the create meeting POST route returns fine in CURL, however, in guzzle it redirects to the GET request.

**Error**  
None showed, as redirected.

**Which App Type (OAuth / Chatbot / JWT / Webhook)?**  
JWT

**Which Endpoint/s?**

> **[Create a Meeting - Meetings - Zoom API - API Reference](https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreate)**
>
> Create a meeting for a user. This API has a daily rate limit of 100 requests per day. Therefore, only 100 Create a Meeting API requests are permitted wi...

**How To Reproduce (If applicable)**  
Steps to reproduce the behavior:

```auto
        //TODO: Cannot get the Guzzle Version to work with POST requests.
        // try {
        // $url = 'users/' . request()->route()->parameter('userId') . '/meetings';
        // $response = $this->client->request('POST', $url, [
        // 'headers' => $this->headers,
        // 'body' => json_encode([
        // 'topic' => 'Hello',
        // 'type' => 2,
        // 'schedule_for' => 'QTk1g81ES_-8FMCOV9Q7bg',
        // 'start_time' => '2020-05-31T12:00:00Z',
        // 'duration' => 30
        // ]),
        // ]);
        // }
        // catch (\GuzzleHttp\Exception\ClientException $e) {
        // $response = $e->getResponse();
        // }
        // return $response;

        $curl = curl_init();

        curl_setopt_array($curl, array(
        CURLOPT_URL => "https://api.zoom.us/v2/users/". request()->route()->parameter('userId') . "/meetings",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => '{"topic": "hello my darling", "type": 2, "start_time": "2020-05-31T12:00:00Z", "duration": 30}',
        CURLOPT_HTTPHEADER => array(
            "authorization: Bearer " . $this->jwt,
            "content-type: application/json"
        ),
        ));

        $response = curl_exec($curl);
        $err = curl_error($curl);

        curl_close($curl);

        if ($err) {
        return $err;
        } else {
        return $response;
        }

```

**Screenshots (If applicable)**  
If applicable, add screenshots to help explain your problem.

**Additional context**  
Add any other context about the problem here.

---

<div class="post-metadata">

**Author:** ![samly](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@samly](https://devforum.zoom.us/u/samly)\
**Post date:** [May 12, 2020, 2:54pm UTC](https://devforum.zoom.us/t/create-meeting-api-returns-get-request-guzzle-php/17222/2 "2020-05-12T14:54:08Z")

</div>

I use Guzzle just fine with POST requests to Zoom.

```php
      $client = new GuzzleHttp\Client();

      $response = $client->request('POST', Zoom::$apiRoot . $apiPath, [
          'query' => $query,
          'json' => $payload,
          'headers' => ['Authorization' => "Bearer " . $auth],
          'http_errors' => false
      ]);

```

where `$payload` is my JSON body and `$query` is the query string, if any.

---

<div class="post-metadata">

**Author:** ![afletcher53](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/afletcher53/32/7784_2.png) [@afletcher53](https://devforum.zoom.us/u/afletcher53)\
**Post date:** [May 12, 2020, 4:12pm UTC](https://devforum.zoom.us/t/create-meeting-api-returns-get-request-guzzle-php/17222/3 "2020-05-12T16:12:31Z")

</div>

I am glad you are able to achieve this, but unfortunately, it still isn’t working for me. The GET routes work fine, but I cannot get my POST route to work with guzzle, as when I send a POST request in postman it returns the get Route.

```auto
     public function createmeeting(Request $request) {
        $payload = json_encode('{"topic": "hello my darling", "type": 2, "start_time": "2020-05-31T12:00:00Z", "duration": 30}');
        try {
             $url = 'users/' . request()->route()->parameter('userId') . '/meetings';
             $response = $this->client->request('POST', $url, [
                'json' => $payload,
                'headers' => $this->headers,
                'http_errors' => false
          ]);
        }
        catch (\GuzzleHttp\Exception\ClientException $e) {
            $response = $e->getResponse();
        }
        return $response;

```

Route.api

```auto
Route::post('ZoomAPI2/users/{userId}/meetings', 'ZoomAPIV2@createmeeting');

```

---

<div class="post-metadata">

**Author:** ![samly](https://avatars.discourse-cdn.com/v4/letter/s/a87d85/32.png) [@samly](https://devforum.zoom.us/u/samly)\
**Post date:** [May 12, 2020, 4:50pm UTC](https://devforum.zoom.us/t/create-meeting-api-returns-get-request-guzzle-php/17222/4 "2020-05-12T16:50:31Z")

</div>

One thing - looks you’re using json\_encode() to encode a string. json\_encode() returns a string, so not sure if that’s useful at all.

Otherwise, how do you know it’s redirecting to a GET? What kind of response is Guzzle giving you?

---

<div class="post-metadata">

**Author:** ![afletcher53](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/afletcher53/32/7784_2.png) [@afletcher53](https://devforum.zoom.us/u/afletcher53)\
**Post date:** [May 12, 2020, 6:48pm UTC](https://devforum.zoom.us/t/create-meeting-api-returns-get-request-guzzle-php/17222/5 "2020-05-12T18:48:21Z")

</div>

Hi,

Yeah the JSON encode thing was because I thought maybe my JSON body wasnt correct, but I think it is.

I only assume its returning the get response (because the response is exactly the same as the get route). i.e. a list of meetings for the user.

Im setting up guzzle in \_\_construct

```auto

    public function __construct(Request $request) {
 
        $api_secret = $_ENV['ZOOM_SECRET_KEY'];
        $api_key = $_ENV['ZOOM_API_KEY'];
        $payload = array(
        'iss' => $api_key,
        'exp' => (time() + 60)
        );
        $this->jwt = JWT::encode($payload, $api_secret);

        //create guzzle client
        $this->client = new \GuzzleHttp\Client(['base_uri' => 'http://api.zoom.us/v2/']);
        $this->headers = [
            'Authorization' => 'Bearer ' . $this->jwt,
            'Accept' => 'application/json',
            'content-type' => 'application/json'
        ];
    } 

```

---

<div class="post-metadata">

**Author:** ![tommy](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/tommy/32/72769_2.png) [@tommy](https://devforum.zoom.us/u/tommy)\
**Post date:** [May 15, 2020, 11:35pm UTC](https://devforum.zoom.us/t/create-meeting-api-returns-get-request-guzzle-php/17222/6 "2020-05-15T23:35:14Z")

</div>

Hey @afletcher53,

Have you tried googling this issue? It seems specific to guzzle. Also double check you are making a POST request and not a GET request.

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![DeveloperBot](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/developerbot/32/12632_2.png) [@DeveloperBot](https://devforum.zoom.us/u/DeveloperBot)\
**Post date:** [August 21, 2020, 9:21pm UTC](https://devforum.zoom.us/t/create-meeting-api-returns-get-request-guzzle-php/17222/7 "2020-08-21T21:21:57Z")

</div>

Closed on August 21, 2020, 9:21pm UTC


