jbogarin / go-cisco-webex-teams

Cisco Webex Teams Go SDK
MIT License
35 stars 25 forks source link

Failed to get one on one conversation #21

Closed Verzu23 closed 2 years ago

Verzu23 commented 2 years ago

"message":"Failed to get one on one conversation","errors":[{"description":"Failed to get one on one conversation"}

markDownMessage := &webexteams.MessageCreateRequest{
        Markdown:      "MESSAGE",
        ToPersonEmail: "MY EMAIL",
    }
    _, rep, err := Client.Messages.CreateMessage(markDownMessage)
    if err != nil {
        fmt.Println(err.Error())
    }

Whats going on here ? If i make manually the request it works... Can you help me?

jbogarin commented 2 years ago

I've never seen that error. Can you send the API request you are doing in curl, postman or something like that?

Verzu23 commented 2 years ago

In Postman I set URL: https://webexapis.com/v1/messages Set Header Authorization: Bearer TOKEN Set body:

And it works as expected

With the library seems execute the same header and body but probably there's something different...

jbogarin commented 2 years ago

I just tested this and it works:


package main
import (
        "fmt"
        "log"
        webexteams "github.com/jbogarin/go-cisco-webex-teams/sdk"
)
var Client *webexteams.Client

func main() {
        Client = webexteams.NewClient()
        markDownMessage := &webexteams.MessageCreateRequest{
                Markdown: "This is a markdown message. *Italic*, **bold** and ***italic/bold***.",
                ToPersonEmail: "blurr@webex.bot",
        }
        newMarkDownMessage, _, err := Client.Messages.CreateMessage(markDownMessage)
        if err != nil {
                log.Fatal(err)
        }
        fmt.Println("POST:", newMarkDownMessage.ID, newMarkDownMessage.Markdown, newMarkDownMessage.Created)
}
Verzu23 commented 2 years ago

The only difference between your code and mine is that I add

Client = webexteams.NewClient()
Client.SetAuthToken("<WEBEX TEAMS TOKEN>")
....

just before

jbogarin commented 2 years ago

That also worked for me.

Verzu23 commented 2 years ago

Okk I'll check it out tomorrow and let you know if I figure out something Thanks