title: Serialized JSON in VB.NET not recognised by web server
body: <p>I'm new to VB.NET and am working on a simple program that will serialize two variables into JSON and POST the data to a web server. The data is being received by the Python server but it is giving an error when trying to deserialize the data.</p>
  
  <p>The inputs are:</p>
  
  <pre><code>tester_id = 2
  operation = "P"
  </code></pre>
  
  <p>When serialized this looks like:</p>
  
  <pre><code>{
    "tester_id": 2,
    "operation": "P"
  }
  </code></pre>
  
  <p>Our server is giving an error and has the following log.</p>
  
  <pre><code>[Sat Aug 19 13:46:53.485257 2017] [:error] [pid 17352] &lt;QueryDict: {u'{\\r\\n  "tester_id": 2,\\r\\n  "operation": "P"\\r\\n}': [u'']}&gt;
  </code></pre>
  
  <p>This suggests that it is receiving a key of:</p>
  
  <pre><code>{u'{\\r\\n  "tester_id": 2,\\r\\n  "operation": "P"\\r\\n}
  </code></pre>
  
  <p>With a value of:</p>
  
  <pre><code>[u'']
  </code></pre>
  
  <p>This isn't correct and I don't understand why it is being received like this, any help is greatly appreciated! See below for the VB.NET code.</p>
  
  <p>Class:</p>
  
  <pre><code>Public Class JSON_get_sensor_id_POST
  Public Property tester_id() As Integer
      Get
          Return m_tester_id
      End Get
      Set(ByVal value As Integer)
          m_tester_id = value
      End Set
  End Property
  Private m_tester_id As Integer
  
  Public Property operation() As String
      Get
          Return m_operation
      End Get
      Set(ByVal value As String)
          m_operation = value
      End Set
  End Property
  Private m_operation As String
  End Class
  </code></pre>
  
  <p>Call function:</p>
  
  <pre><code>    Dim set_tester_id As Integer = 1
      Dim set_operation As String = "P"
      Dim manuf_url As String = "https://XYZ...."
  
      Dim JSON_to_send As New JSON_get_sensor_id_POST
      JSON_to_send.tester_id = set_tester_id
      JSON_to_send.operation = set_operation
  
      Dim postData = JsonConvert.SerializeObject(JSON_to_send, Formatting.Indented)
      Dim return_object = POST_to_Server(manuf_url, postData)
  </code></pre>
  
  <p>Upload Function:</p>
  
  <pre><code>Private Function POST_to_Server(ByVal post_url As String, ByVal JSON_to_post As Object)
      Dim user_login As String = "blah@blah.com"
      Dim user_pass As String = "blah"
  
      Dim myCache As New CredentialCache()
      myCache.Add(New Uri(post_url), "Basic", New NetworkCredential(user_login, user_pass))
  
      ' Create a request using a URL that can receive a post.   
      Dim request As WebRequest = WebRequest.Create(post_url)
      ' Set the Method property of the request to POST.  
      request.Credentials = myCache
      request.Method = "POST"
      request.ContentType = "application/json"
      ' Create POST data and convert it to a byte array.  
      Dim byteArray As Byte() = Encoding.Default.GetBytes(JSON_to_post)
      ' Set the ContentLength property of the WebRequest.  
      request.ContentLength = byteArray.Length
      ' Get the request stream.  
      Dim dataStream As Stream = request.GetRequestStream()
      ' Write the data to the request stream.  
      dataStream.Write(byteArray, 0, byteArray.Length)
      ' Close the Stream object.  
      dataStream.Close()
      ' Get the response.  
      Dim response As WebResponse = request.GetResponse()
      ' Display the status.  
      Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
      ' Get the stream containing content returned by the server.  
      dataStream = response.GetResponseStream()
      ' Open the stream using a StreamReader for easy access.  
      Dim reader As New StreamReader(dataStream)
      ' Read the content.  
      Dim responseFromServer As String = reader.ReadToEnd()
      ' Display the content.  
      DebugMessage(responseFromServer)
      ' Clean up the streams.  
      reader.Close()
      dataStream.Close()
      response.Close()
      Dim myObject = JsonConvert.DeserializeObject(Of JSON_sensor_id_request_return)(responseFromServer)
      Return myObject
  
  End Function
  </code></pre>