# HTTP Post request

**URL:** <https://community.particle.io/t/http-post-request/44153>\
**Category:** Libraries\
**Created:** [September 25, 2018, 8:52am UTC](https://community.particle.io/t/http-post-request/44153 "2018-09-25T08:52:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbsa](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kbsa/32/18291_2.png) [@kbsa](https://community.particle.io/u/kbsa)\
**Post date:** [September 25, 2018, 8:52am UTC](https://community.particle.io/t/http-post-request/44153/1 "2018-09-25T08:52:17Z")

</div>

Hi there! I am having a huge problem using the Httpsclient-particle library. All I want to do is to POST a Json object to my server that is located on Heroku. I have tested everything on the backend and it works like it should. The only problem is that my code somehow does not work. I am repeatedly getting status 400.  
This should be simple POST, so i really dont want to work with Webhooks or any thing like that.

For obvious reasons and I will change my host site to something else.

PS: I am using a Particle Photon.

```auto
#include <HttpClient.h>
#include "application.h"

 HttpClient http;  
 http_header_t headers[] = {  
    { "Content-Type", "application/json" },
    { "Host" , "https://www.myserver.com"},
    { NULL, NULL }   
 };
 
 http_request_t request;  
 http_response_t response; 

void setup(){
  Serial.begin(baudRate);
  Postrequest();
  
}

void loop(){
     //In this part I will calculate the BPM.. So its unnecessary to show you guys this part.

}
void Postrequest(){

   request.port = 80;
   request.path = "/api/something";  
   request.body = "{\"name\":\"personsname\", \"datetime\":\"02:00\", \"bpm\":\"90\"}";  
   http.post(request, response, headers);
   Particle.publish("METHOD", String(response.status)); 
   
}

```

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [September 25, 2018, 9:00am UTC](https://community.particle.io/t/http-post-request/44153/2 "2018-09-25T09:00:50Z")

</div>

> [@kbsa](#):
>
> ```auto
> { "Host" , "https://www.myserver.com"}
> 
> ```

So that's not really tha case

> [@kbsa](#):
>
> This should be simple POST, so i really dont want to work with Webhooks or any thing like that.

Since it's a HTTPS server you'd need a HTTPS connection which is not in the scope of the HTTPClient library nor is there native support on the devices.

However, you'd also need to set `request.hostname` (without the protocol prefix) and not only state the host in the headers.

---

<div class="post-metadata">

**Author:** ![kbsa](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kbsa/32/18291_2.png) [@kbsa](https://community.particle.io/u/kbsa)\
**Post date:** [September 25, 2018, 9:27am UTC](https://community.particle.io/t/http-post-request/44153/3 "2018-09-25T09:27:24Z")

</div>

Do you have any suggestions how I should tackle this task? I have never done https request with particle before.  
My backend is created with Node.js with simple endpoints and deployed on Heroku. I have searched everywhere for a solution. But can’t seem to find any 😕

Appreciate the help 🙂

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [September 25, 2018, 9:46am UTC](https://community.particle.io/t/http-post-request/44153/4 "2018-09-25T09:46:07Z")

</div>

I'd not go down that rabbit hole.  
There are some libraries that tried to leverage secure connetions for user applications with Particle devices but they are (often) cumbersome to use and rather heavy on the memory of the device.  
The simplest way will either be to change your server to accept HTTP or go for webhooks.

some links

> [@HTTPS client is here for the Photon! - by the glowfi.sh Team](https://community.particle.io/t/https-client-is-here-for-the-photon-by-the-glowfi-sh-team/15934):
>
> Hey Community, We have been working hard at glowfi.sh to deliver an HTTPS client for the Particle community and I am happy to say we are ready to release it thanks to all the work by glowfi.sh engineer @jersey99. Our client is built from matrixSSL, and you can check out our documentation, specs, and examples in our glowfishAPI repo for Particle [here](https://github.com/glowfishAPI/httpsclient-particle). Again, we are super excited to release this and welcome any comments, feedback, pull requests, etc.! Thanks Mike and the glowfi.sh Team [Sign u…](https://api.glowfi.sh/register)

> [@axTLS library \[client: testing, debugging, documenting\]](https://community.particle.io/t/axtls-library-client-testing-debugging-documenting/33889):
>
> This port is about 90% done. I am soliciting any helpers at this point. I am using the mbedTLS/TlsTclClient library as a template. The main goal of this is to get [https://things.ubidots.com](https://things.ubidots.com) working. I have tried a myrad of compile combinations with the old and the development version of mbedTLS. It will connect to many other https sites but not the Ubidots site. Plain unix curl works fine so, these libraries should work as well. I just wanted to give a shout out that there is a work…

> [@Wolfssl \[version 0.0.2; documenting\]](https://community.particle.io/t/wolfssl-version-0-0-2-documenting/34131):
>
> Hi, I’m working on getting WolfSSL up and running for Photon/P1, but I keep running into problems that I’m having a hard time solving. They have a [really good guide](https://www.wolfssl.com/wolfSSL/Docs-wolfssl-manual-5-portability.html) for how to do this and I’ve solved most of the configuration issues up until now. I don’t have anything that works yet though and I’m suspecting this has to do with the fact that WolfSSL is C and the Particle compiler have a preference for CPP? I’m pretty sure that the error above indicates a larger problem (unknown type name ‘clas…

---

<div class="post-metadata">

**Author:** ![jenschr](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/jenschr/32/4792_2.png) [@jenschr](https://community.particle.io/u/jenschr)\
**Post date:** [September 25, 2018, 10:07am UTC](https://community.particle.io/t/http-post-request/44153/5 "2018-09-25T10:07:53Z")

</div>

Sorry for not replying to this earlier: I have the Particle port of WolfSSL up and running with Amazon AWS IoT on about 150 devices now thanks to @cermak’s great effort on porting. As @ScruffR says - it’s a memory hog and it complicates things quite a bit, but it works really well.

WolfSSL chews up about 70k of your 128k app memory, but makes it possible to talk to AWS IoT directly. The WolfSSL port can talk to any TLS server directly via TCP and it handles the exchange of certificates and setup of communications quite fast. If you need anything above the TCP layer, you’ll just write that to fit your application.
