# Getting err: 400 Bad Request when creating a meeting

**URL:** <https://devforum.zoom.us/t/getting-err-400-bad-request-when-creating-a-meeting/39167>\
**Category:** API and Webhooks\
**Created:** [December 25, 2020, 8:33am UTC](https://devforum.zoom.us/t/getting-err-400-bad-request-when-creating-a-meeting/39167 "2020-12-25T08:33:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![littlechad](https://avatars.discourse-cdn.com/v4/letter/l/57b2e6/32.png) [@littlechad](https://devforum.zoom.us/u/littlechad)\
**Post date:** [December 25, 2020, 8:33am UTC](https://devforum.zoom.us/t/getting-err-400-bad-request-when-creating-a-meeting/39167/1 "2020-12-25T08:33:52Z")

</div>

**Description**  
I am using `POST: https://api.zoom.us/v2/users/me/meetings` to create a meeting using go, here’s my code

```
// Create ...
func (zm *ZoomMeeting) Create(data *model.Talk) (*ZoomMeetingResponse, error) {
	payloads := &ZoomMeetingRequest{
		Agenda: data.Description,
		Duration: data.Duration,
		Password: "1234qwer",
		Timezone: data.TimeZone,
		Topic: data.Title,
		Type: int64(2),
		Settings: &ZoomMeetingSettingsRequest{
			ApprovalType: int64(0),
			Audio: "both",
			AutoRecording: "none",
			CnMeeting: false,
			HostVideo: true,
			InMeeting: false,
			JoinBeforeHost: false,
			MuteUponEntry: true,
			ParticipantVideo: true,
			RegistrationType: int64(2),
			RegistrantsEmailNotification: false,
			UsePmi: false,
			Watermark: false,
		},
		StartTime: data.DateTimeStart.Format("2006-01-02T03:04:05Z"),
	}

	payloadsByte, err := json.Marshal(payloads)
	if err != nil {
		return nil, err
	}

	request, err := http.NewRequest(
		"POST",
		"https://api.zoom.us/v2/users/me/meetings",
		bytes.NewBuffer(payloadsByte),
	)
	if err != nil {
		return nil, err
	}
	request.Header.Add("content-type", "application/json")
	request.Header.Add("authorization", fmt.Sprintf("Bearer %s", zm.Provider.GetAccessToken()))

	resp, err := zm.Client.Do(request)
	if err != nil {
		return nil, err
	}

	if resp.StatusCode != 200 {
		a := fmt.Sprintf("Create zoom meeting err: %s", resp.Status)
		return nil, errors.New(a)

	}
	defer resp.Body.Close()

	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}

	result := ZoomMeetingResponse{}

	if err := json.Unmarshal(body, &result); err != nil {
		return nil, err
	}

	return &result, nil
}

```

Here’s the printed request

```
&{
Method:POST 
URL:https://api.zoom.us/v2/users/me/meetings 
Proto:HTTP/1.1 
ProtoMajor:1 
ProtoMinor:1 
Header:map[
   Authorization:[Bearer ...] 
   Content-Type:[application/json]] 
   Body:{
      Reader:{
         "agenda":"\u003cp\u003eZoom meeting creation example\u003c/p\u003e\n",
         "duration":30,
         "password":"1234qwer",
         "timezone":"Asia/Jakarta",
         "topic":"Zoom meeting creation example",
         "type":2,
         "settings":{
            "audio":"both",
            "auto_recording":"none",
            "host_video":true,
            "mute_upon_entry":true,
            "participant_video":true,
            "registration_type":2
         },
         "start_time":"2020-12-26T12:00:00Z"
      }
   }
   ...
}

```

**Error**  
The error from this line

```
if resp.StatusCode != 200 {
   a := fmt.Sprintf("Create zoom meeting err: %s", resp.Status)
   return nil, errors.New(a)
}

```

Reads: `[ERROR] Create zoom meeting err: 400 Bad Request`

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

Oauth

**Which Endpoint/s?**

[https://api.zoom.us/v2/users/me/meetings](https://api.zoom.us/v2/users/me/meetings)

---

<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:** [December 28, 2020, 6:00pm UTC](https://devforum.zoom.us/t/getting-err-400-bad-request-when-creating-a-meeting/39167/2 "2020-12-28T18:00:36Z")

</div>

Hey @littlechad,

Typically the 400 Bad Request error is thrown when the request body is invalid.

> [@littlechad](#):
>
> `Reader:{`

Can you help explain what the `Reader` object is? Are you sending the `Reader` object as apart of the request body? If you could log your request body in JSON format before you make the request, and share it here, we can debug further. 🙂

Thanks,  
Tommy

---

<div class="post-metadata">

**Author:** ![littlechad](https://avatars.discourse-cdn.com/v4/letter/l/57b2e6/32.png) [@littlechad](https://devforum.zoom.us/u/littlechad)\
**Post date:** [December 29, 2020, 2:29pm UTC](https://devforum.zoom.us/t/getting-err-400-bad-request-when-creating-a-meeting/39167/3 "2020-12-29T14:29:50Z")

</div>

Hi Tommy,

the `Reader` thingy is golang [io.Reader](https://golang.org/pkg/io/#Reader) interface returned from this line `bytes.NewBuffer(payloadsByte)`, since the [http.NewRequest()](https://golang.org/pkg/net/http/#NewRequest) method requires it as the third argument.

Anyway the actual issue turns out to be the `zm *ZoomMeeting` interface i initiated beforehand, and i actually manage to solve this issue, by rewriting the `http.Client` for `ZoomMeeting.Client`

Sorry to bother your holiday, thanks for taking your time to reply to this, Happy new year 🙂

---

<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:** [December 29, 2020, 6:30pm UTC](https://devforum.zoom.us/t/getting-err-400-bad-request-when-creating-a-meeting/39167/4 "2020-12-29T18:30:45Z")

</div>

Hey @littlechad,

Happy to hear you got it sorted out! 🙂

Thanks for sharing the solution as well!

Happy near year!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [January 29, 2021, 4:30am UTC](https://devforum.zoom.us/t/getting-err-400-bad-request-when-creating-a-meeting/39167/5 "2021-01-29T04:30:46Z")

</div>

Closed on January 29, 2021, 4:30am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
