10 Replies Latest reply on Dec 22, 2014 7:53 AM by userc_13500

    Using wiced_http_get for posting JSON

      Hi there


      I tried to sending data using HTTP POST using the wiced_http_get function, as below, but the body doesn't seem to be coming through correctly.


      #define EXAMPLE_POST \
          "POST /post_test HTTP/1.1\r\n" \
          "Host:\r\n" \
          "Accept: */* \r\n"\
          "Content-Type: application/json \r\n" \
          "Content-Length: %d \r\n" \
          "%s" \


      and then


      sprintf(body_json,"{\"value\":\"%u\" }", 32); //Simple JSON example
      sprintf(post, EXAMPLE_POST, strlen(body_json),body_json );
      WPRINT_APP_INFO(( post )); //This result looks correct
      wiced_http_get(&ip_address, post, buffer, BUFFER_LENGTH);



      I've tried including different structured bodies, and different Content-Type's i.e. application/x-www-form-urlencoded to no luck.


      Using Wireshark, the package seems to be structured correctly. But any HTTP endpoints I've tried (Node.js, Xively etc.) just view the package sent as gibberish. Could this be a low-level TCP issue, in that wiced_http_get was not designed for bodies?


      Or is there a better recommended way for structuring POST bodies in the WICED SDK?




      Another interesting note is that using LwIP, Wireshark would not pick up the packets. Can anyone recommend a cause/workaround?