Spark Core & Temboo (Spreadsheet) --> Http Error 0 and 404

Hi,

I am using mySparkCore and the Temboo Library to post data (temperature) to a google spreadsheet. But to minimize errors, I just want to send the value 10. Everything compiles fine but I get two errors in the Terminal window:

First one:

Triggered! Calling /Library/Google/Spreadsheets/AppendRow...
Sensor: 10
HTTP_CODE
0

Second one:

Triggered! Calling /Library/Google/Spreadsheets/AppendRow...
Sensor: 10
HTTP_CODE
404
 Not Found
Cache-control: no-cache="set-cookie"
Date: Thu, 07 May 2015 12:38:53 GMT
Server: Jetty(8.1.7.v20120910)
Set-Cookie: AWSELB=97AB4DACC029EAA0BEB2C9C09AD7F655A5A7917720B43EAA49EE8316A71DB57443ED9759DE46E81076D5FCDBBB8D22D3F366FBE16318709B32E4B856658AECAF3385E5C5;PATH=/
Connection: Close

Error
The specified Credential object doesn't exist, or you don't have the necessary permissions to access it.

My Code:

#include "application.h"
#include "Temboo/Temboo.h"
#include "TembooAccount.h"

/* 
Copy the three #define values from the TembooAccount.h file you generated on 
Teboo's web site or include the file in your Spark Cloud IDE

The same TembooAccount.h file settings can be used for all Temboo SDK sketches.  
Keeping your account information in a separate file means you can share the 
main .ino file without worrying that you forgot to delete your credentials.
*/
/*
#define TEMBOO_ACCOUNT "<your account name>"  // Your Temboo account name 
#define TEMBOO_APP_KEY_NAME "<temboo app key name>"  // Your Temboo app key name
#define TEMBOO_APP_KEY "<temboo app key>"  // Your Temboo app key
*/
void runAppendRow(int sensorValue);

TCPClient client;

// The number of times to trigger the action if the condition is met.
// We limit this so you won't use all of your Temboo calls while testing.
int maxCalls = 5;

// The number of times this Choreo has been run so far in this sketch.
int calls = 0;
int count = 0;

void setup() {
  Serial.begin(9600);
  
  // For debugging, wait until the serial console is connected.
  delay(4000);
  //while(!Serial.available());
  
  Serial.println("Setup started...");
  delay(5000);
  // Initialize pins
  pinMode(A0, INPUT);
  pinMode(7, OUTPUT);
  Serial.println("Setup complete.\n");
}

void loop() {
  int sensorValue = 10;//analogRead(A0);
  
  Serial.println("Sensor: " + String(sensorValue));
  
  if (sensorValue != 0) {
    if (calls < maxCalls) {
      Serial.println("\nTriggered! Calling /Library/Google/Spreadsheets/AppendRow...");
  
      runAppendRow(sensorValue);
      //digitalWrite(6, HIGH);
      calls++;
    } else {
      Serial.println("\nTriggered! Skipping the action to save Temboo calls during testing.");
      Serial.println("You can adjust or remove the calls/maxCalls if() statement to change this behavior.\n");
    }
  }
  delay(2500);
}

void runAppendRow(int sensorValue) {
  TembooChoreo AppendRowChoreo(client);

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

  // Set profile to use for execution
  AppendRowChoreo.setProfile("GXLSSoil");
  
  String sensorValueStr = (String)sensorValue;//analogRead(A0);
  Serial.println("Sensor: " + sensorValueStr);
  AppendRowChoreo.addInput("RowData", sensorValueStr);
  // Set Choreo inputs
  //AppendRowChoreo.addInput("RowData", String(sensorValue));

  
  // Identify the Choreo to run
  AppendRowChoreo.setChoreo("/Library/Google/Spreadsheets/AppendRow");

  // Run the Choreo
  unsigned int returnCode = AppendRowChoreo.run();

  // A return code of zero means everything worked
  if (returnCode == 0) {
    Serial.println("Done!\n");
  } else {
    // A non-zero return code means there was an error
    // Read and print the error message
    while (AppendRowChoreo.available()) {
      char c = AppendRowChoreo.read();
      Serial.print(c);
    }
    Serial.println();
  }
  
  AppendRowChoreo.close();
}

I would be verygrateful if you could help me solve this issue :smile:
Kind regards,
Tom

@hl68fx, you declared sensorValue in loop() so it acts as a local variable. It will not be seen in runAppendRow(). I am surprised that the compiler did not flag that but that may be due to the (String) cast before it. Change the variable to a global and see what happens :smile:

1 Like

Hi peekay123,

thank you very much for your help! I have made sensorValue global. Error 0 is now solved. :smile: But error 404 is still there.

Error 404:

Triggered! Calling /Library/Google/Spreadsheets/AppendRow...
Sensor: 10
HTTP_CODE
404
 Not Found
Cache-control: no-cache="set-cookie"
Date: Thu, 07 May 2015 13:16:23 GMT
Server: Jetty(8.1.7.v20120910)
Set-Cookie: AWSELB=97AB4DACC029EAA0BEB2C9C09AD7F655A5A7917720B43EAA49EE8316A71DB57443ED9759DE46E81076D5FCDBBB8D22D3F366FBE16318709B32E4B856658AECAF3385E5C5;PATH=/
Content-Length: 113
Connection: Close

Error
The specified Credential object doesn't exist, or you don't have the necessary permissions to access it.

My code:

#include "application.h"
#include "Temboo/Temboo.h"
#include "TembooAccount.h"

/* 
Copy the three #define values from the TembooAccount.h file you generated on 
Teboo's web site or include the file in your Spark Cloud IDE

The same TembooAccount.h file settings can be used for all Temboo SDK sketches.  
Keeping your account information in a separate file means you can share the 
main .ino file without worrying that you forgot to delete your credentials.
*/
/*
#define TEMBOO_ACCOUNT "<your account name>"  // Your Temboo account name 
#define TEMBOO_APP_KEY_NAME "<temboo app key name>"  // Your Temboo app key name
#define TEMBOO_APP_KEY "<temboo app key>"  // Your Temboo app key
*/
void runAppendRow(int sensorValue);

TCPClient client;

// The number of times to trigger the action if the condition is met.
// We limit this so you won't use all of your Temboo calls while testing.
int maxCalls = 5;

// The number of times this Choreo has been run so far in this sketch.
int calls = 0;
int count = 0;

int sensorValue = 10;

void setup() {
  Serial.begin(9600);
  
  // For debugging, wait until the serial console is connected.
  delay(4000);
  //while(!Serial.available());
  
  Serial.println("Setup started...");
  delay(5000);
  // Initialize pins
  pinMode(A0, INPUT);
  pinMode(7, OUTPUT);
  Serial.println("Setup complete.\n");
  //Spark.publish("Setup complete");
}

void loop() {
  
  
  Serial.println("Sensor: " + String(sensorValue));
  
  if (sensorValue != 0) {
    if (calls < maxCalls) {
      Serial.println("\nTriggered! Calling /Library/Google/Spreadsheets/AppendRow...");
  
      runAppendRow(sensorValue);
      //digitalWrite(6, HIGH);
      calls++;
    } else {
      Serial.println("\nTriggered! Skipping the action to save Temboo calls during testing.");
      Serial.println("You can adjust or remove the calls/maxCalls if() statement to change this behavior.\n");
    }
  }
  delay(2500);
}

void runAppendRow(int sensorValue) {
  TembooChoreo AppendRowChoreo(client);

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

  // Set profile to use for execution
  AppendRowChoreo.setProfile("GXLSSoil");
  
  String sensorValueStr = (String)sensorValue;//analogRead(A0);
  Serial.println("Sensor: " + sensorValueStr);
  AppendRowChoreo.addInput("RowData", sensorValueStr);
  // Set Choreo inputs
  //AppendRowChoreo.addInput("RowData", String(sensorValue));

  
  // Identify the Choreo to run
  AppendRowChoreo.setChoreo("/Library/Google/Spreadsheets/AppendRow");

  // Run the Choreo
  unsigned int returnCode = AppendRowChoreo.run();

  // A return code of zero means everything worked
  if (returnCode == 0) {
    Serial.println("Done!\n");
  } else {
    // A non-zero return code means there was an error
    // Read and print the error message
    while (AppendRowChoreo.available()) {
      char c = AppendRowChoreo.read();
      Serial.print(c);
    }
    Serial.println();
  }
  
  AppendRowChoreo.close();
}

@hl68fx, this error stands out:

Error
The specified Credential object doesn’t exist, or you don’t have the necessary permissions to access it.

Are your TEMBOO_ account, key_name and key credentials correct and valid?

1 Like

I solved my problem! :smile:
I forgot to change the profile name in the sample app. Now everything works fine :blush:

Thank you very much for your help peekay123!

Kind regards
Tom

1 Like