Help SendEmail HTTP Bad Request 400

Hello, i need help!
My code in Arduino Ethernet Shield is:

#define Modem 7

#include <SPI.h>
#include <Dhcp.h>
#include <Dns.h>
#include <Ethernet.h>
#include <EthernetClient.h>
#include <Temboo.h>
#include "TembooAccount.h" // Contains Temboo account information

byte ethernetMACAddress[] = ETHERNET_SHIELD_MAC;
IPAddress ip(192,168,0,170);
EthernetServer server(8080);
EthernetClient client;
byte ipC[] = {192, 168, 0, 170};

byte COD = B1000;
int numRuns = 1; // Execution count, so this doesn't run forever
int maxRuns = 10; // Maximum number of times the Choreo should be executed

String A3_carga = "Reniciar Modem";
boolean A3_estado = false;
boolean loop1 = false;

void setup() {
Serial.begin(9600);

// For debugging, wait until the serial console is connected
delay(4000);
while(!Serial);

Ethernet.begin(ethernetMACAddress, ip);

Serial.println("OK");
delay(5000);

pinMode(Modem,OUTPUT);

Serial.println("Setup complete.\n");

sendMail();
}

void loop() {

acionamentos();
client = server.available();
//client.connect(ipC, 80);

if (client)
{

boolean currentLineIsBlank = true; // A requisição HTTP termina com uma linha em branco Indica o fim da linha
String valPag;

while (client.connected())
{
if (client.available())
{

char c = client.read(); //Variável para armazenar os caracteres que forem recebidos
valPag.concat(c); // Pega os valor após o IP do navegador ex: 192.168.0.170/0001

if(valPag.endsWith("0100")) //Senão se o que for pego após o IP for igual a 0100
{
COD = COD ^ B0100; //Executa a lógica XOR entre a variável atual de COD e o valor B0010
A3_estado = !A3_estado; //Inverte o estado do terceiro acionamento
}
//=========================================================================================================================

if (c == '\n' && currentLineIsBlank)
{
//Inicia página HTML
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print(" ");
//=========================================================================================================================

client.print("

");

//Terceiro BOTAO
client.print("<button onclick="window.location.href='http://192.168.0.170:8080/0100'">\0 > Codigo: 0100 > ");
if(A3_estado)
{
client.print("<span style="color: #00ff00;">");
client.print(A3_carga);
client.print(" - ON");
client.print("
");
}
else
{
client.print("<span style="color: #ff0000;">");
client.print(A3_carga);
client.print(" - OFF");
client.print("
");
}
//=========================================================================================================================

client.print("

");

//=========================================================================================================================

client.print(" <meta http-equiv="refresh" content="5; url=http://192.168.0.170:8080/\"> ");

client.println("");

break;

} //Fecha if (c == '\n' && currentLineIsBlank)

} //Fecha if (client.available())

} //Fecha While (client.connected())

delay(3);// Espera um tempo para o navegador receber os dados
client.stop(); // Fecha a conexão

} //Fecha if(client)

}

void acionamentos()
{
if(A3_estado) digitalWrite(Modem,HIGH);
else digitalWrite(Modem,LOW);
}

void sendMail(){

TembooChoreo SendEmailChoreo(client);

// Invoke the Temboo client
SendEmailChoreo.begin();

// Set Temboo account credentials
SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT);
SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME);
SendEmailChoreo.setAppKey(TEMBOO_APP_KEY);

// Set Choreo inputs
String FromAddressValue = ""Modem Casa"";
SendEmailChoreo.addInput("FromAddress", FromAddressValue);
String UsernameValue = "caiolightbr@gmail.com";
SendEmailChoreo.addInput("Username", UsernameValue);
String SubjectValue = "Aviso Modem";
SendEmailChoreo.addInput("Subject", SubjectValue);
String ToAddressValue = "grilocaio@hotmail.com";
SendEmailChoreo.addInput("ToAddress", ToAddressValue);
String MessageBodyValue = "Seu modem foi reniciado";
SendEmailChoreo.addInput("MessageBody", MessageBodyValue);
String PasswordValue = "my code of gmail";
SendEmailChoreo.addInput("Password", PasswordValue);

// Identify the Choreo to run
SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail");

// Run the Choreo; when results are available, print them to serial
SendEmailChoreo.run();

while(SendEmailChoreo.available()) {
char c = SendEmailChoreo.read();
Serial.print(c);
}
SendEmailChoreo.close();
client.println("");

}

But when I execute, I have this problem:

OK
Setup complete.

Enviando email!
HTTP_CODE
400
Bad Request
Content-Type: text/html; charset=iso-8859-1
Date: Mon, 02 May 2016 21:04:21 GMT
Vary: Accept-Encoding
Content-Length: 316
Connection: Close

400 Bad Request

Bad Request

Your browser sent a request that this server could not understand.


Apache/2.2.22 (Ubuntu) Server at devlight.temboolive.com Port 443

Please help me!
Thanks!

Hi there, I work for Temboo.

Its possible you could be running into an out of memory situation. This can cause the Choreo data to get overwritten and corrupted, which is why it appears that there is a problem with your Temboo code even though it looks correct. You could look at using a profile for your Choreo inputs. A profile allows you to simply reference your inputs from your sketch without including all of the String data that consumes memory. You can learn more about that approach here:

You can also try removing any unneeded Serial.print statements.

Let us know if this helps. If you have any questions, feel free to contact us at Documentation | Temboo.

kbuck3:
Hi there, I work for Temboo.

Its possible you could be running into an out of memory situation. This can cause the Choreo data to get overwritten and corrupted, which is why it appears that there is a problem with your Temboo code even though it looks correct. You could look at using a profile for your Choreo inputs. A profile allows you to simply reference your inputs from your sketch without including all of the String data that consumes memory. You can learn more about that approach here:

Save RAM and Program your Microcontroller Remotely with Temboo Profiles

You can also try removing any unneeded Serial.print statements.

Let us know if this helps. If you have any questions, feel free to contact us at Documentation | Temboo.

Hello,
I'm already using Temboo profile, but also to need my local network, ie has a temboo and has mine as I finish my profile and open a new one? For this new not use the old information.
Thank you

Hi there,

I didn't see a profile in the code you posted. The profile stores Choreo inputs and will not affect anything with your local network. If you need to use information that is not in the profile, you just need to set an input like you normally would for a Choreo.

Hopefully this helps. If you have any questions, please show any changes you've made to your code to use a profile and we'll be happy to help.