Sim 800L + HTTP request

Hi,

I am facing issue with GET request, it seems that my link to api is too long and Serial is not printing it. When I am trying other shorter links all works as I need. Does anyone found a solution for it?

This is part of code where I have shorter URLs and all works:

  gsmCommand("AT+HTTPINIT");
  printSerialData(1000);
  gsmCommand("AT+HTTPPARA=\"CID\",1");
  printSerialData(1000);

  if(alarmStatus)
  {
    gsmCommand("AT+HTTPPARA=\"URL\",\"http://www.google.pl\"");
  } else {
    gsmCommand("AT+HTTPPARA=\"URL\",\"http://www.wp.pl\"");
  }
  printSerialData(5000);
  gsmCommand("AT+HTTPACTION=0");
  printSerialData(10000);
  gsmCommand("AT+HTTPTERM");
  printSerialData(1000);

and serial prints depend on "alarm Status" true or false:

17:00:58.465 -> AT+HTTPPARA="CID",1 17:00:58.603 -> OK 17:00:59.729 -> AT+HTTPPARA="URL","http://www.wp.pl" 17:00:59.763 -> OK 17:01:04.763 -> AT+HTTPACTION=0 17:01:04.866 -> OK 17:01:10.377 -> 17:01:10.377 -> +HTTPACTION: 0,301,162 17:01:20.416 -> AT+HTTPTERM 17:01:20.521 -> OK

17:06:27.502 -> AT+HTTPPARA="CID",1 17:06:27.636 -> OK 17:06:28.762 -> AT+HTTPPARA="URL","http://www.google.pl" 17:06:28.898 -> OK 17:06:33.889 -> AT+HTTPACTION=0 17:06:34.026 -> OK 17:06:41.313 -> 17:06:41.313 -> +HTTPACTION: 0,200,12484 17:06:51.365 -> AT+HTTPTERM 17:06:51.468 -> OK

When I am switching to API URL it doesn't work.:

  if(alarmStatus)
  {
    gsmCommand("AT+HTTPPARA=\"URL\",\"http://api.thingspeak.com/update?api_key=E5N5JYOJIIYZISNO&field1=0\"");
  } else {
    gsmCommand("AT+HTTPPARA=\"URL\",\"http://api.thingspeak.com/update?api_key=E5N5JYOJIIYZISNO&field1=1\"");
  }

Serial output not print URL at all:

17:12:13.005 -> AT+HTTPPARA="CID",1 17:12:13.005 -> OK 17:12:13.998 -> AT+HTTPACTION=0 17:12:19.160 -> ERROR 17:12:29.170 -> AT+HTTPTERM 17:12:29.307 -> OK

Funny thing is that when I am not using if and always sending same API URL, all works fine, just Serial is not showing URL fully, but anyway works as I need....

gsmCommand("AT+HTTPINIT");
  printSerialData(1000);
  gsmCommand("AT+HTTPPARA=\"CID\",1");
  printSerialData(1000);

//  if(alarmStatus)
//  {
//    gsmCommand("AT+HTTPPARA=\"URL\",\"http://api.thingspeak.com/update?api_key=E5N5JYOJIIYZISNO&field1=0\"");
//  } else {
    gsmCommand("AT+HTTPPARA=\"URL\",\"http://api.thingspeak.com/update?api_key=E5N5JYOJIIYZISNO&field1=1\"");
//  }

17:18:39.485 -> AT+HTTPPARA="CID",1 17:18:39.623 -> OK 17:18:40.718 -> AT+HTTPPARA="URL","http://api.thingspeak.com/update?api_key=E5N5AT+HTTPACTION=0 17:18:45.957 -> OK 17:18:52.348 -> 17:18:52.348 -> +HTTPACTION: 0,200,2 17:19:02.400 -> AT+HTTPTERM 17:19:02.535 -> OK

Thanks in advance for help.

My guess is something somewhere else in your program you haven’t shown us. An array index out of bounds, buffer overflow, etc.

Thanks for your reply. I guess that maybe buffer is full… but let me share full code with you, it’s still in draft, so don’t look at not smartest ideas :stuck_out_tongue:

code.ino (9.76 KB)