Vonage / vonage-dotnet-sdk

Vonage REST API client for .NET, written in C#. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
https://developer.vonage.com/
Apache License 2.0
106 stars 82 forks source link

Hi, I followed the online guide trying to make a outbound call, using "nexmo csharp client3.2.2", but i still got the exception"System.ArgumentException: 'RsaUsingSha alg expects key to be of RSA type". I've already tried the way you mention as post earlier but it didn't work. I'm total clueless now, please help me #131

Closed lidondon closed 5 years ago

lidondon commented 5 years ago

Thank you for making this library better by submitting an issue. To ensure we can troubleshoot effectively, please fill out this form in its entirety.

If you are submitting a feature request you may ignore this template and enter a free-form description of your request. You may also contact the maintainers directly via the Nexmo Slack to discuss the feature.

General description of the issue or question

(Please be as descriptive as possible. If this is a general Nexmo question (billing, usage, etc.) you will receive a better experience by either filing a support request directly to Nexmo or asking in the Nexmo Slack.)

Which target framework(s) of .NET can you reproduce this issue against?

(Examples: .NET Core 2.0, netcoreapp1.0, .NET Framework 4.6.2, etc.)

What operating system(s) is exhibiting this issue?

Version or commit hash

Which version(s) of CSharp.Nexmo.Client did you encounter this issue?

Expected Behavior

What should have happened?

Actual Behavior

What actually happened?

Steps to Reproduce

Please provide a code snippet or steps to reproduce the issue.

smithrobs commented 5 years ago

Which target framework(s) of .NET can you reproduce this issue against?

What operating system(s) is exhibiting this issue?

lidondon commented 5 years ago

it's 4.6.1 in win10. Is there anything i should do?

lidondon commented 5 years ago

anther little problem.....i'm curious about the key in the 'private.key' file break line not totally continuous, Client = new Client(creds: new Nexmo.Api.Request.Credentials { ApiKey = "my api key", ApiSecret = "My sceret", ApplicationId = "app id", ApplicationKey=(should i contain -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----) });

smithrobs commented 5 years ago

I would not recommend removing line breaks (I believe doing so does not adhere to specs) and yes, you must include the -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY-----

lidondon commented 5 years ago
actually, i've tried anything i can imagine, i mean....like include the line breaks, begin and end symbols, 

still getting the same 'RsaUsingSha alg expects key to be of RSA type' exception. i read the post with same issue before, so i copy and paste the content of 'private.key' not give Nexmo.Api.Request.Credentials.ApplicationKey the path of the file. am i correct to do so? i have been stuck here with this issue almost 2days, please help me, thank you sooooooooooooooooo much

lidondon commented 5 years ago

I did it again from the beginning, then i got "System.ArgumentNullException: 'Arg_ParamName_Name'" here's my code below: var results = Client.Call.Do(new Call.CallCommand { to = new[] { new Call.Endpoint { type = "phone", number = "886989306026" } }, answer_url = new[] { "https://nexmo-community.github.io/ncco-examples/first_call_talk.json" } });

smithrobs commented 5 years ago
lidondon commented 5 years ago

ok, here's the full code below

public void MakeCall() { Client = new Client(creds: new Nexmo.Api.Request.Credentials { ApiKey = "[api key]", ApiSecret = "[secret]", ApplicationId = "703b9c80-c49f-48e6-bf3d-34b1e99bbc6e", ApplicationKey = @"-----BEGIN PRIVATE KEY----- [private.key] -----END PRIVATE KEY----- " });

        var results = Client.Call.Do(new Call.CallCommand
        {
            to = new[]
            {
                new Call.Endpoint {
                    type = "phone",
                    number = "886989306026"
                }
            },
            answer_url = new[]
            {
                "https://nexmo-community.github.io/ncco-examples/first_call_talk.json"
            }
        });
    }

}

do i need to do anything about JWT?? but i didn't see this mentioned in the online guide

smithrobs commented 5 years ago

JWT is handled for you when needed.

from is not optional. Per the readme:


client.Call.Do(new Call.CallCommand
{
    to = new[]
    {
        new Call.Endpoint {
            type = "phone",
            number = TO_NUMBER
        }
    },
// *** this is required!
    from = new Call.Endpoint
    {
        type = "phone",
        number = NEXMO_NUMBER
    },
// *** this is required! ^^^
    answer_url = new[]
    {
        "https://nexmo-community.github.io/ncco-examples/first_call_talk.json"
    }
});```
lidondon commented 5 years ago

but, i saw that if for outbound call, 'from' is optional? coz i did'n rent a number from nexmo. and i've tried that intended to delete from on playground, it worked. so, if i did not rent a number yet, what should i do with this nexmo ccharp client? thanks a lot

smithrobs commented 5 years ago

I'm not sure where you saw that (note that the Playground may have different and/or less strict requirements from using the API itself), but check out the official docs at https://developer.nexmo.com/voice/voice-api/building-blocks/make-an-outbound-call/dotnet and Step 2 of the prerequisites

lidondon commented 5 years ago

got it, thank you very much.....but i can't purchase a number (country: Taiwan), could you tell me how can i do?

lidondon commented 5 years ago

thank for your supporting first. now i finally place the first outbound call, that's a text- to-speech. in our scenario is that we want our customer supports can call our client on our website with nexmo voice api, but i don't know....um....i mean i don't know what NCCO should be like? or is it a outbound or inbound call? could you plz give me some guides? thanks a lot

lidondon commented 5 years ago

hi, now i can make a outbound call and i can get the event (app's event url). thank you again. but i still have some problems needs to fix. first, i'm confused that the call flow depends on new Call.CallCommand().answer_url (the ncco i create)? or the property in new Call.CallCommand() { to = new[] { new Call.Endpoint { type = "phone", number = "886905990870" <== my phone } }, from = new Call.Endpoint { type = "phone", number = "12013801211" <== i rent from nexmo } . . }); the second, i tried to change "from" from nexmo_number to my another phone, but fail.. the third, i pick up the call (call from my nexmo_number) then no voice, but the time is going how can i pick up the phone (nexmo_number)?? thanks

lidondon commented 5 years ago

hello? It's been two days..... please give me a direction, thanks

judy2k commented 5 years ago

Hi @lidondon,

You may be better off contacting support@nexmo.com for these issues - you're having trouble using the Nexmo service more than raising issues against this dotnet client library. I'll attempt to answer your questions as best I can though.

1: The call flow depends on the NCCO data you provide at the URL you set as answer_url. 2: You can only make outgoing calls from a Nexmo number or to a Nexmo number. You can't use the Nexmo APIs to manage calls between two non-Nexmo numbers. 3: I'm guessing that you're setting an incorrect NCCO URL, or that the NCCO data is incorrect. You should check your development server log to see if any requests are being received.

lidondon commented 5 years ago

Hi, judy2k thanks for your kindness supporting, actually everything works fine now