Sorry, you need to enable JavaScript to visit this website.

You are here

Needed: Good simple example of how to send a message using c#

10 posts / 0 new
Last post

Trevor's picture
by Trevor

Needed: Good simple example of how to send a message using c#
Hi Folks, Looking for a code example that shows how to use the messaging api to send an SMS. This will be the development entry point for a complicated integration project using Microsoft Dynamics CRM and probably Azure, so it would be very handy if it was easy to understand. TrevorM.

Trevor's picture
by Trevor

add app does not find anything...
on the Add Apps and Keys page, the add app button doesn't ever seem to find anything.  It would be really nice if it did find something if I enter messaging and c#...

Trevor's picture
by Trevor

Provisioning a number.
It would also be excellent if the link to "provision a number" was able to be found...

DeveloperSteve's picture
by DeveloperSteve

Hi Trevor, 

Hi Trevor, 

We have just pushed 1.0.2 of the dotnet sdk to the repo https://github.com/telstra/MessagingAPI-SDK-dotnet

Ive got a code sample i can share using that if it helps. 

Re the apps and keys page, the button not finding anything > are you not getting a page appear to create and name a app? if not what browser and OS are you using so i can try and replicate. 

Re provision number > what page are you on to get the not found response to provisioning?

Trevor's picture
by Trevor

C#

Hi Steven, a c# code sample that creates a rest service using the Messaging API was what I was looking for.

What I was having trouble doing was provisioning the phone number etc, on dev.telstra.com/user/<mynumber>/apps/add page.
so far, it times out every time.
Today I go further and got to setup the app name, and click the add app button. but it seems stuck there. (request timeout 504)

Note that we are a corporate client of Telstra with a quick connection and we don't seem to suffer delays on other web pages.

P.S. I remember a presentation you made at the Newcastle Coders group - I still have the paypal t-shirt...

Trevor's picture
by Trevor

I have probably asked the
I have probably asked the wrong question. I have downloaded the api. I need to compile an executable that calls the library. What I guess that I'm looking for is a sample of the the calls required to
  • setup the connection,
  • pass the authentication tokens and finally
  • pass a message to the service.  
does that make more sense?

Trevor's picture
by Trevor

Getting closer. where to I

Getting closer. where to I find the grantType I need to specify?

Trevor's picture
by Trevor

Getting closer. where to I

Getting closer. where to I find the grantType I need to specify?

System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'com.telstra.messaging.Client.Configuration' threw an exception.

Inner Exception 1:
FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=3......d' or one of its dependencies.
The system cannot find the file specified.

Trevor's picture
by Trevor

In: public

In: public AuthenticationApi(Configuration configuration = null)
{
if (configuration == null) // use the default one in Configuration
this.Configuration = Configuration.Default;

Configuration.Default returns an error.

DeveloperSteve's picture
by DeveloperSteve

HI Trevor, 

HI Trevor, 

Yep makes sense, 

grantType = "client_credentials"

using System;
using System.Diagnostics;
using com.telstra.messaging.Api;
using com.telstra.messaging.Client;
using com.telstra.messaging.Model;

namespace Example
{
    public class Example
    {
        public void main()
        {

            var apiInstance = new AuthenticationApi();
            var clientId = clientId_example;  // string | 
            var clientSecret = clientSecret_example;  
            var grantType = "client_credentials";  

                OAuthResponse result = apiInstance.AuthToken(clientId, clientSecret, grantType);

        }
    }
}

then the token you get back from that call will be stored in part of the object response (namely access_token) that you use in 

Configuration.Default.AccessToken = "YOUR_ACCESS_TOKEN";

Also heres a vid that might help https://youtu.be/Uf95cmM8ZcY 

Log in or register to post comments