Favoriot post json in vb net

Internet of Things IoT Frameworks 2 years ago

0 0 0 0 0

_x000D_ _x000D_ I am looking for solution to encounter my problem. This curl post as your reference to figure out post json data to Favoriot.com platform. curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'apiKey: YOUR API KEY HERE' -d '{ "device_developer_id": "deviceDefault@FAVORIOT", "data": { "temperature": "31","humidity": "70"} }' As I mentioned above, trying to post using vb net.. I attached the source code as your reference. Imports Newtonsoft.Json Imports System.Net Imports System.Text Public Class Form1 Private urlToPost As String = "" Private apikey_favoriot As String = "YOUR API KEY HERE" Public Sub New(ByVal urlToPost As String) Me.urlToPost = urlToPost End Sub Public Function postData(ByVal dictData As Dictionary(Of String, Object)) As Boolean Dim webClient As New WebClient() Dim resByte As Byte() Dim resString As String Dim reqString() As Byte Try webClient.Headers("content-type") = "application/json" webClient.Headers.Add("apikey", apikey_favoriot) reqString = Encoding.Default.GetBytes(JsonConvert.SerializeObject(dictData, Formatting.Indented)) resByte = webClient.UploadData(Me.urlToPost, "post", reqString) resString = Encoding.Default.GetString(resByte) Console.WriteLine(resString) webClient.Dispose() Return True Catch ex As Exception Console.WriteLine(ex.Message) End Try Return False End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Form1 As New Form1("http://192.168.254.104:8000") Dim dictData As New Dictionary(Of String, Object) dictData.Add("device_developer_id", "deviceDefault@FAVORIOT") dictData.Add("data", "temperature : 31") Form1.postData(dictData) End Sub End Class

Posted on 16 Aug 2022, this text provides information on IoT Frameworks related to Internet of Things. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Answers (0)

Post Answer

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum


Q

Azure IoT hub and sending messages with mosquitto_pub

_x000D_ _x000D_ I'm trying to send some simple message with mosquitto_pub to Azure IoT HUB but faced...
Q

How to generate AWS bootstrap certificates with java SDK?

_x000D_ _x000D_ According to this docs I need to generate so-called bootstrap certificates for my Io...
Q

is it possible to do 3way handshake only one time with mqtt communication?

_x000D_ _x000D_ I am using mosquitto_pub to publish the data with TLS using a topic. I am using mosq...

Important Internet of Things Links