Favoriot post json in vb net

Internet of Things IoT Frameworks . 2 years ago

  0   0   0   0   0 tuteeHUB earn credit +10 pts

5 Star Rating 5 Rating
_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.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Write Your Comments or Explanations to Help Others



Tuteehub forum answer Answers (0)


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.

Important Internet of Things Links

tuteehub community

Join Our Community Today

Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.

tuteehub community