Having troubles to orignate
newChannelKey := ari.NewKey(ari.ChannelKey, url.QueryEscape(fmt.Sprintf("channel:%s", endpoint+time.Now().String())))
log.Printf("Originate call to %s\n", newChannelKey)
channel, err := client.Channel().Originate(newChannelKey, ari.OriginateRequest{
Endpoint: endpoint,
Extension: "s",
Context: "inbound",
Priority: 1,
CallerID: endpoint, // Optional: Set CallerID if you want to override [email protected]
Timeout: 30,
})
here endpoint value is
PJSIP/superfone_number/sip:[email protected]: Non-2XX response: 400 Bad Request
the same work in dial() in extension but how to achive same where I want to call this [email protected] it exist on kamilio
(edited for formatting/readability)
That channel ID is a real mess, and while you are escaping it for URL usage, I suspect it is still going to have invalid characters from Asterisk's point of view.
There's a reason we have the rid package in this library: to construct resource IDs.
newChannelKey := ari.NewKey(ari.ChannelKey, rid.New(rid.Channel))
Then, if you really need to know the timestamp of that, you can get it back with:
ts, err := rid.Timestamp(newChannelKey.ID)
But that will give you a nice, completely valid channel ID with no special characters.
Oh, I think you're trying to pass the new, non-existent channel key into Originate as the first argument. The first argument to Originate is a related channel, from which ari can determine which Asterisk node to schedule it and from which Asterisk can determine how to most advantageously configure the new channel to work with it (such as avoiding transcoding).
See the comment on the Originate function: https://pkg.go.dev/github.com/CyCoreSystems/ari#Channel
If you don't have a related channel, just pass nil as the first argument.