Vonage/vonage-dotnet-code-snippets

Transfer a call sample code

icebeam7 opened this issue · 3 comments

According to the Voice API Reference, there are 6 possible actions that can be used to modify an in-progress call: hangup, mute, unmute, earmuff, unearmuff, and transfer.

The VoiceController shows how to perform all but the last action, so I would like to contribute to the repository by implementing the transfer call sample code.

Ok, so I've implemented the following code but I receive a value cannot be null exception:

var result = Client.Call.Edit(NEXMO_CALL_UUID, new Call.CallEditCommand
{
     action = "transfer",
     destination = "{\"type\": \"ncco\", \"url\": [\"https://developer.nexmo.com/ncco/transfer.json\"]}"
});

The problem seems to be the serialization process done by the API regarding the destination property (because of the quotes). This element is declared as string, but I think it should be an instance of some class (which in turn would be correctly serialized and used by the API without any problem).

Could somebody please confirm this or point me in the right direction?

I have also tried other code for the destination property, but the result remains the same:

destination = JsonConvert.SerializeObject(new { type = "ncco", url = new[] { "https://developer.nexmo.com/ncco/transfer.json" } })

Hi @icebeam7 ,
Indeed there was an issue with the Edit call command and this now is fixed in V3.2.4 .
So the code for transfer would look like this now :

var result = Client.Call.Edit(NEXMO_CALL_UUID, new Call.CallEditCommand
            {
                Action = "transfer",
                Destination = new Call.Destination
                {
                    Type = "ncco",
                    Url = new[] { "LINK_TO_NEW_NCCO" }
                }

Please feel free to PR this and I'm looking forward for more contributions from you :)