this is using the mbed os version 5-13-1

Dependencies:   mbed-http

Revision:
90:ed0267eca7b5
Parent:
74:f26e846adfe9
--- a/source/wifi_demo.cpp	Mon Apr 01 08:00:41 2019 +0000
+++ b/source/wifi_demo.cpp	Sun Apr 07 10:52:37 2019 +0000
@@ -13,7 +13,14 @@
     for (size_t ix = 0; ix < res->get_headers_length(); ix++) {
         device->printf("\t%s: %s\n", res->get_headers_fields()[ix]->c_str(), res->get_headers_values()[ix]->c_str());
     }
+    char * body = (char *) res->get_body();
     device->printf("\nBody (%lu bytes):\n\n%s\n", res->get_body_length(), res->get_body_as_string().c_str());
+        for (size_t ix = 0; ix < res->get_body_length(); ix++) {
+        device->printf("%02X: ", body[ix]);
+        if((ix % 32) == 0 and ix)
+        device->printf("\n");
+    }
+
 }
 
 void completed(){
@@ -53,6 +60,7 @@
     wait(1); // wait for 1 sec 
 
     mbed_trace_init();
+#ifdef RUN_ALL    
     wait(1); // wait for 1 sec 
 
     // GET request to os.mbed.com
@@ -201,7 +209,6 @@
     }
 
     wait(1); // wait for 1 sec 
-
     // POST request to httpbin.org
     if(false)
     {
@@ -230,6 +237,61 @@
 
         delete post_req;
     }
+    
+#endif
+    
+        // POST request to dev2.dnanudge.io
+    if(true)
+    {
+        device->printf("\n----- HTTPS POST request to dev2.dnanudge.io -----\n");
+        TLSSocket*            socket;
+        socket = new TLSSocket();
+        char hostName[] = "dev2.dnanudge.io";
+        nsapi_error_t r;
+        // make sure to check the return values for the calls below (should return NSAPI_ERROR_OK)
+        r = socket->open(network);
+        if(r != NSAPI_ERROR_OK)
+        { 
+            printf("TLS open failed!!\n");
+            return 0;
+        }
+        printf("TLS open passed!!\n");
+        r = socket->set_root_ca_cert(SSL_CA_PEM);
+        if(r != NSAPI_ERROR_OK)
+        { 
+            printf("TLS set_root_ca_cert failed!!\n");
+            return 0;
+        }
+        printf("TLS set_root_ca_cert passed!!\n");
+        r = socket->connect(hostName, 443);
+        if(r != NSAPI_ERROR_OK)
+        { 
+            printf("TLS connect failed for hostname %s!!\n", hostName);
+            return 0;
+        }
+        printf("TLS connection successful for https site :  %s\n", hostName);
+        //HttpsRequest* post_req = new HttpsRequest(network, SSL_CA_PEM, HTTP_POST, "https://dev2.dnanudge.io/nudgebox/v1");
+        HttpsRequest* post_req = new HttpsRequest(socket, HTTP_POST, "https://dev2.dnanudge.io/nudgebox/v1");
+        //post_req->set_header("Content-Type", "application/json");
+        post_req->set_header("Accept", "*/*");
+        post_req->set_header("Content-Type", "application/octet-stream");
+        post_req->set_header("Content-Length", "20");
+
+        const char body[] = {0x00, 0x08, 0x6a, 0x48, 0xf8, 0x2d, 0x8e, 
+                             0x82, 0x01, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x00, 0x00, 0x67, 
+                             0xc3, 0x19, 0xf8};
+        HttpResponse* post_res = post_req->send(body, 20);
+        if (!post_res) {
+            device->printf("HttpRequest failed (error code %d)\n", post_req->get_error());
+            return 1;
+        }
+
+        device->printf("\n----- HTTPS POST response from dev2.dnanudge.io -----\n");
+        dump_response(post_res);
+
+        delete post_req;
+    }
+
      wait(1); // wait for 1 sec 
      delete device;
      return 0;