EDIT: Thank you for the answer, also we had figured out how to do it Micropython too - I believe that it is relevant for the Arduino/ESP8266/ESP32 community to share this too.


How should I include parameters from, to and message to http.post?

Is this the correct way to do it? http.POST("'from:+XXXXX','to:+XXXXX','message:Hej'");

#include <M5StickC.h>
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiMulti.h>

#include <HTTPClient.h>

#define USE_SERIAL Serial

WiFiMulti wifiMulti;

void setup() {



    for(uint8_t t = 4; t > 0; t--) {
        USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);

    wifiMulti.addAP("YYYY", "ZZZZZ");


void loop() {
    // wait for WiFi connection
    if((wifiMulti.run() == WL_CONNECTED)) {

        HTTPClient http;

        USE_SERIAL.print("[HTTP] begin...\n");
        // configure traged server and url

          http.addHeader("Content-Type", "application/x-www-form-urlencoded"); 
          http.setAuthorization("XXXXX", "YYYYYY");
          int httpCode = http.POST("'from:+XXXXX','to:+XXXXX','message:Hej'");

        USE_SERIAL.print("[HTTP] GET...\n");
        // start connection and send HTTP header
         httpCode = http.GET();

        // httpCode will be negative on error
        if(httpCode > 0) {
            // HTTP header has been send and Server response header has been handled
            USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);

            // file found at server
            if(httpCode == HTTP_CODE_OK) {
                String payload = http.getString();
        } else {
            USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());


  • what does the server expect? x-www-form-urlencoded format is name=value&nextname=nextvalue. so with = as name value separator and & as name-value pairs separator.
    – Juraj
    Apr 18, 2020 at 8:04

1 Answer 1


What format of message does the server expect?
As you send "x-www-form-urlencoded" it should probably look like:


where the different parts are


 param .... Name of the expected parameter
 = .... divides the param pair
 paramValue .... Content/value of the parameter
 & .... links the param pairs

so in your case

 int httpCode = http.POST("from=+XXXXX&to=+XXXXX&message=Hej");
  • 1
    Note that, in x-www-form-urlencoded, the “+” character is used to encode a space. If you mean a literal “+”, you should encode it as “%2B”. Apr 18, 2020 at 12:44
  • My friend and I figured out how to do this in micropython - can I make a question about it and answer it or should I post it here somehow? github.com/46elks/46elks-getting-started/blob/master/…
    – Rene
    May 2, 2020 at 11:55
  • Place the link and short explanation as an EDIT to your question, this way everything is together and helps others Thank you May 2, 2020 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.