How to send int array with ESP8266 http post request? I'm reading RFID cards' UID with an ESP8266 and trying to send that information to my web server hosted on a Raspberry Pi. I'm currently storing the UID in an int array, but the http.POST(); function takes a string input. I tried adding each UID digit together, but that doesn't work either.
How would you go about sending the uid in the request?
My code:
    /*
    Created by TheCircuit
*/

#define SS_PIN 4  //D2
#define RST_PIN 5 //D1

#include &lt;SPI.h&gt;
#include &lt;MFRC522.h&gt;

#include &lt;ESP8266WiFi.h&gt;
#include &lt;ESP8266HTTPClient.h&gt;
#include &lt;WiFiClient.h&gt;

const char* ssid = &quot;****&quot;;
const char* password = &quot;****&quot;;
const char* serverName = &quot;****&quot;;
int RELAY = 2; //D6

int UIDs[1][4] = {
  {83, 111, 39, 47}
};

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

void setup()
{
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522

  pinMode(RELAY, OUTPUT);
  digitalWrite(RELAY, HIGH);

  WiFi.begin(ssid, password);
  Serial.println(&quot;Connecting&quot;);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(&quot;.&quot;);
  }
  Serial.println(&quot;&quot;);
  Serial.print(&quot;Connected to WiFi network with IP Address: &quot;);
  Serial.println(WiFi.localIP());
}

boolean compareUIDs(int a[4], int b[4]) {
  for (int i = 0; i &lt; 4; i++) {
    if (a[i] != b[i]) return false;
  }

  return true;
}

void loop()
{
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent())
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial())
  {
    return;
  }

  // mfrc522.PICC_DumpToSerial(&amp;(mfrc522.uid));

  int UID[4];
  for (int i = 0; i &lt; 4; i++) {
    UID[i] = mfrc522.uid.uidByte[i];
  }

  Serial.print(UID[0]);
  Serial.print(&quot; &quot;);
  Serial.print(UID[1]);
  Serial.print(&quot; &quot;);
  Serial.print(UID[2]);
  Serial.print(&quot; &quot;);
  Serial.print(UID[3]);
  Serial.println();

  for (int i = 0; i &lt; sizeof(UIDs); i++) {
    boolean success = compareUIDs(UIDs[i], UID);
    if (success) {
      Serial.println(&quot;ACCESS GRANTED&quot;);
      digitalWrite(RELAY, LOW);

      if (WiFi.status() == WL_CONNECTED) {
        HTTPClient http;

        // Your Domain name with URL path or IP address with path
        http.begin(serverName);

        // Specify content-type header
        http.addHeader(&quot;Content-Type&quot;, &quot;application/json&quot;);
        
        int httpResponseCode = http.POST(&quot;UID GOES HERE&quot;);

        Serial.print(&quot;HTTP Response code: &quot;);
        Serial.println(httpResponseCode);

        // Free resources
        http.end();
      }

      delay(2000);
      digitalWrite(RELAY, HIGH);
      return;
    }
  }
}
You could use the (awesome) ArduinoJSON library, but likely overkill for this app. I found it more useful to parse JSON than to construct it.
You could simply print to a buffer and the POST that:
char payload[MAX_PAYLOAD];
sprintf(payload, &quot;{\&quot;uid1\&quot;:%d,\&quot;uid2\&quot;:%d,\&quot;uid3\&quot;:%d,\&quot;uid4\&quot;:%d}&quot;, UID[0], UID[1], UID[2], UID[3]);

http.POST(payload);


You would #define MAX_PAYLOAD with a value that will be sufficient to hold all the information.
Notice that sprintf allows you to use any formatting options you want (e.g. hexadecimal, etc).
If you wanted to send it as an array:
sprintf(payload, &quot;{\&quot;uid\&quot;:[%d,%d,%d,%d]}&quot;, UID[0], UID[1], UID[2], UID[3]);