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?