Using header in HTTP request with AT command via SIM800l?

Hello,

I am working on project with Arduino board and SIM800L module. I want to make GET request and with simple request it is working fine.

But I need to add a header to my GET request, more specifically "X-Api-Key". I am reading the SIM800l documentation (HTTP commands on page 256), but I can't figure it out.

I think I should use AT+HTTPPARA or AT+HTTPDATA, but not sure and don't know the right syntax.

Here is my code:

#include <SoftwareSerial.h>

//Create software serial object to communicate with SIM800L
SoftwareSerial mySerial(3, 2); //SIM800L Tx & Rx is connected to Arduino #3 & #2


void setup()
{
  digitalWrite(8, HIGH);
  pinMode(8, OUTPUT);
  digitalWrite(8, LOW);
  delay(100);
  digitalWrite(8, HIGH);
  //Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
  Serial.begin(115200);

  //Begin serial communication with Arduino and SIM800L
  mySerial.begin(9600);

  Serial.println("Initializing...");
  delay(3000);

  mySerial.println("AT"); 
  updateSerial();
  delay(2000);
  mySerial.println("AT+SAPBR=3,1,\"APN\",\"internet.vivacom.bg\""); 
  updateSerial();
  delay(1200);
  mySerial.println("AT+SAPBR=3,1,\"USER\",\"VIVACOM\""); 
  updateSerial();
  delay(1100);
  mySerial.println("AT+SAPBR=3,1,\"PWD\",\"VIVACOM\""); 
  delay(1100);
  updateSerial();
  mySerial.println("AT+SAPBR=1,1"); 
  updateSerial();
  delay(2200);
 mySerial.println("AT+HTTPINIT"); 
  updateSerialt();
  delay(300);
  mySerial.println("AT+HTTPPARA=\"CID\",1"); 
  updateSerial();
  delay(300);
  mySerial.println("AT+HTTPPARA=\"URL\",\"theWebsite.com\""); 
  updateSerial();
  delay(300);
  mySerial.println("AT+HTTPACTION=0"); 
  updateSerial_();
  delay(1500);
  mySerial.println("AT+HTTPREAD"); 
  updateSerialt()
  delay(500);
  mySerial.println("AT+HTTPTERM"); 
  updateSerial();
  delay(300);

void loop()
{
  updateSerial();
  delay(1000);
}

void updateSerial()
{
  delay(1500);
  while (Serial.available())
  {
    mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
  }
  while (mySerial.available())
  {
    Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
  }
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.