twilio / twilio-go

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

Passing Custom Code to Verifications Fails #210

Open dylanreich opened 10 months ago

dylanreich commented 10 months ago

Issue Summary

invalid memory address or nil pointer dereference when passing a custom code.

Steps to Reproduce

Pass a value to setCustomCode. If this line is commented, verifications are created just fine and the SMS is received.

Code Snippet

client := twilio.NewRestClientWithParams(twilio.ClientParams{
        Username: accountSid,
        Password: authToken,
    })

    params := &verify.CreateVerificationParams{}
    params.SetCustomCode("867530")
    params.SetTo(t_int.Phone)
    params.SetChannel("sms")

    resp, err := client.VerifyV2.CreateVerification(verificationSid, params)
    if err != nil {
        fmt.Println(err.Error())

        return c.Status(http.StatusBadRequest).JSON(fiber.Map{
            "status": resp.Status,
            "err":    err.Error(),
        })
    } else {
        return c.Status(http.StatusOK).JSON(fiber.Map{
            "status": resp.Status,
        })
    }

Exception/Log

Invalid parameter: Code (null) More info: https://www.twilio.com/docs/errors/60200
runtime error: invalid memory address or nil pointer dereference

Technical details: