Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad request because of bad URL encoding for dates #28

Open
thpiron opened this issue Aug 15, 2022 · 0 comments
Open

Bad request because of bad URL encoding for dates #28

thpiron opened this issue Aug 15, 2022 · 0 comments

Comments

@thpiron
Copy link

thpiron commented Aug 15, 2022

Hello,

The dates used in query params don't use the webex API format: ISO8601.
So the server returns a 400 BAD REQUEST with the message: "The request could not be understood by the server due to malformed syntax.".

To reproduce:

package main

import (
	"fmt"
	"log"
	"time"

	webexteams "github.com/jbogarin/go-cisco-webex-teams/sdk"
)

// Client is Webex Teams API client
var Client *webexteams.Client

func main() {
	Client = webexteams.NewClient()

	myRoomID := "<yourRoomID>"

	messageQueryParams := &webexteams.ListMessagesQueryParams{
		RoomID: myRoomID,
		Before: time.Date(2022, time.August, 15, 0, 22, 12, 0, time.UTC),
	}

	messages, resp, err := Client.Messages.ListMessages(messageQueryParams)
	if err != nil {
		log.Fatal(err)
	}
	if resp.IsError() {
		log.Fatal(string(resp.Body()))
	}
	for id, message := range messages.Items {
		fmt.Println("GET:", id, message.ID, message.Text, message.Created)
	}
}

This PR fixes the issue: #27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant