Sample Visual Basic Code to Post Http 1.0 PUT Method to Thingspeak Channel - Small Error | ThingSpeak API | Forum


Please consider registering

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
Sample Visual Basic Code to Post Http 1.0 PUT Method to Thingspeak Channel - Small Error
No permission to create posts
January 18, 2018
10:11 pm
New Member
Forum Posts: 2
Member Since:
January 18, 2018
sp_UserOfflineSmall Offline

Newbie Programmer

Trying to modify existing code developed many years back for pachube feed to be compatible with Thingspeak upload using Microsoft Visual Basic.

It appears to successfully login, as there are no error and the entries denotes transfers taking place, but the data for field5 is not updated. Must be a simple formatting error and would like support from those in the know.

Here is my VB code


Dim PachubeStream As String = "&field5=20"

'prepare to Upload the latest changed data to pachube (ThingSpeak) for on-line data storage and plotting

Dim myWebClient As New WebClient()

uploaddatapachubekey = "XXXXXXXXXXXXX"

myWebClient.Headers.Add("Content-Type", "text/csv")

' Apply ASCII Encoding to obtain the string as a byte array.

Dim byteArray As Byte() = Encoding.ASCII.GetBytes(PachubeStream)

'configure uploaddata pachube port url

uploaddatapachubeport = "" + uploaddatapachubekey

'UploadData input string using Http 1.0 PUT Method if not in test mode

If TestMode = False Then myWebClient.UploadData(uploaddatapachubeport, "post", byteArray)

'reinitialize data comparitor for next pass

Catch fail As Exception

Console.WriteLine("The process failed: {0}.", fail.ToString())

End Try

January 21, 2018
7:08 pm

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

Are you sure TestMode=false?  That would cause the client to not upload the data.  Your formatting of the REST call looks fine.  I'm not familiar with your library specifically, but there is usually a data size indicator in the POST command.

For example, you can see the steps in this example.  I assume your client library takes care of that itself, but I thought I would mention it just in case.  Also you might double check the write API key.

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
17 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