twilio / twilio-go

A Go package for communicating with the Twilio API.
MIT License
278 stars 40 forks source link

Error response when sending SMS messages #130

Open cbrake opened 2 years ago

cbrake commented 2 years ago

Issue Summary

Yesterday when trying to send SMS messages, I got the following error:

Error sending SMS: error decoding the response for an HTTP error code: 503: invalid character '<' looking for beginning of value

This happened perhaps 6 or so times,, so I instrumented the Twilio code to get more information, but I've not been able to reproduce the issue since.

I think the error is being created here:

https://github.com/twilio/twilio-go/blob/main/client/client.go#L80

Technical details:

I'm in the processing of switching from github.com/kevinburke/twilio-go to this package, so would like to know if anyone else has seen this, or if its just a transient problem.

shwetha-manvinkurke commented 2 years ago

Sounds like an issue on the backend but we could probably make the logging better on the helper library side. This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.

fostemi commented 2 months ago

I am receiving the same error when I'm running the tutorial. What was the solution to this error? I've been trying to get more verbose error from twilio but the best I can visualize is the parameters are incorrect because there are many values.

cmy235 commented 1 month ago

I had a similar issue, which was resolved once I removed the message service SID param from CreateMessageParams in the CreateMessage call. In my case it wasn't actually necessary. If you are using a messaging service SID, perhaps confirm the number you're sending from is part of that service.

SWFullPotential commented 1 month ago

I am also experiencing this issue. Was there any fix?

creating client like so:

twilioClient := twiliogo.NewRestClientWithParams(twiliogo.ClientParams{
            Username:   cfg.Twilio.APIKey,
            Password:   cfg.Twilio.Auth,
            AccountSid: cfg.Twilio.AccountSID,
        })

followed example like so

    params := &twilioApi.CreateMessageParams{}
    params.SetTo(myphoneNumber)
    params.SetFrom(n.fromSMS)
    params.SetBody("Hello from Go!")

    resp, err := twilioClient.Api.CreateMessage(params)
    if err != nil {
        fmt.Println("Error sending SMS message: " + err.Error())
    } else {
        response, _ := json.Marshal(*resp)
        fmt.Println("Response: " + string(response))
    }

and getting that Error sending SMS message: error decoding the response for an HTTP error code: 400: invalid character '<' looking for beginning of value

SWFullPotential commented 1 month ago

@shwetha-manvinkurke has this been looked at ? this issue was created back in 2021 and so far i don't see a resolution.

kevinburkesegment commented 1 month ago

Hi all - if you can share any information about what version of the library you are running, and how you downloaded it, that would help a lot - we'd like to fix this.



import "github.com/twilio/twilio-go/client"
import "fmt"
import "runtime"

func main() {
    fmt.Println(client.LibraryVersion)
    fmt.Println(runtime.Version())
}
SWFullPotential commented 1 month ago

lib version: 1.22.0 runtime version: go1.22.4

i ran go get for all the twilio packages i'm using.

kevinburkesegment commented 1 month ago

Hi @SWFullPotential version 1.22.0 had an error and has since been retracted. Please try v1.22.2 and see if you are still experiencing problems. Thanks!

SWFullPotential commented 1 month ago

omg thank you.. I thought i tried that already whoops. thank you.. it's working now