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


Please consider registering


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

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

Forum Posts: 158
sp_UserOfflineSmall Offline
January 21, 2018 - 7:08 pm
sp_Permalink sp_Print

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:
38 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:







Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565


Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee