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

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





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

Register Lost password?
sp_Feed sp_TopicIcon
How to add a TalkBack command from a Xamarin.Forms app
Avatar
alombardi
New Member
Forum Posts: 2
sp_UserOfflineSmall Offline
1
January 4, 2018 - 4:31 pm
sp_Permalink sp_Print

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 

 

Avatar
cstapels
Moderator
Forum Posts: 158
sp_UserOfflineSmall Offline
2
January 4, 2018 - 7:52 pm
sp_Permalink sp_Print

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.

Avatar
alombardi
New Member
Forum Posts: 2
sp_UserOfflineSmall Offline
3
January 5, 2018 - 8:36 am
sp_Permalink sp_Print

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:
35 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

ibgedubo

aogomaeqaza

ureomug

itixuwidouzuv

eilimir

memozupi

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee