How to add a TalkBack command from a Xamarin.Forms app | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
How to add a TalkBack command from a Xamarin.Forms app
No permission to create posts
January 4, 2018
4:31 pm
Avatar
alombardi
New Member
Members
Forum Posts: 2
Member Since:
January 4, 2018
sp_UserOfflineSmall Offline

Hello,

I would like to know if it is possible to add (also delete, modify, ...) a TalkBack command from a mobile Xamarin.Form app written in C#. I tried with several fragments of codes without success. One of them is the following:

async static void PostRequest(string url)

{

      IEnumerable<KeyValuePair<string, string>> queries = new List<KeyValuePair<string, string>>()
     {
          new KeyValuePair<string, string>("api_key","XXXXXXXXXXXXXXXX"),
          new KeyValuePair<string, string>("command_string","Alarm")
      };

      HttpContent q = new FormUrlEncodedContent(queries);
      q.Headers.Clear();
      q.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

      using (HttpClient client = new HttpClient())
     {  
          using (HttpResponseMessage response = await client.PostAsync(url, q))
          {
               using (HttpContent content = response.Content)
               {
                    string mycontent = await content.ReadAsStringAsync();
                    HttpContentHeaders headers = content.Headers;
                    str = headers.ToString();
               }
          }
      }

}

and I called this method using

PostRequest("https://api.thingspeak.com/talkbacks/XXXXX/commands");

 

This is not working. I think that I am passing the parameters api_key and command_string in a wrong way.

Any help is welcome! Thanks,

 

Ariel 

 

January 4, 2018
7:52 pm
Avatar
cstapels
Moderator
Members


Moderators
Forum Posts: 258
Member Since:
March 7, 2017
sp_UserOfflineSmall Offline

What you are trying should definitely be possible.

The syntax looks correct to me.  Can you try the post with POSTMAN or curl as see if it is added correctly?  That will make sure the api key is the correct one and the talkback id is correct.

January 5, 2018
8:36 am
Avatar
alombardi
New Member
Members
Forum Posts: 2
Member Since:
January 4, 2018
sp_UserOfflineSmall Offline

Thank you cstapels! Sorry, the problem was with the internet connection of the android emulator.The syntax was correct and also the parameters.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
22 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

terranceqh2, DianeEmids, Alanawaype, uqovitay, ufijifode, manish01

Administrators: Hans: 387, lee: 457