grokify/go-ringcentral-client

SendSMS() fails with error MSG-246 if extensionNumber is encoded in MessageStoreCallerInfoRequest

Closed this issue · 0 comments

julbr commented

Calling apiClient.MessagesApi.SendSMS(context.TODO(), "~", "~", sms)
with sms:

	sender := rc.MessageStoreCallerInfoRequest{
		PhoneNumber: "+12222222222",
	}
	customer := rc.MessageStoreCallerInfoRequest{
		PhoneNumber: "+111111111111",
		Name:        "test customer",
		Location:    "NY",
	}
	var customers []rc.MessageStoreCallerInfoRequest = []rc.MessageStoreCallerInfoRequest{customer}
	sms := rc.CreateSmsMessage{
		From: &sender,
		To:   customers,
		Text: "test from Go!",
	}

I get this error:

Status: 400 Bad Request, Body: {
  "errorCode" : "InvalidParameter",
  "message" : "Sending SMS from/to extension numbers is not available",
  "errors" : [ {
    "errorCode" : "MSG-246",
    "message" : "Sending SMS from/to extension numbers is not available"
  } ]
}

Suggested fix:

Update messageStoreCallerInfoRequest.go:15 to:

ExtensionNumber string `json:"extensionNumber,omitempty"

This omits the ExtensionNumber from the message when it's not specified, and results in a successful SendSMS call.