Using MKR GSM 1400 to post to Hologram's Dashboard

Hi guys, I have a problem dealing with a program to send a data to the Hologram’s dashboard.
So the program is design to send a temperature data once the program runs, and then the MKR will disconnected. I am using a JSON String and the main code was provided by Hologram.

The problem is when I use the JSON String, it cannot read variable and always send error in the dashboard, whereas if I use keywords using (" "), the message inside can be seen in the dashboard.

Can anyone help me to send the data variable or someone having the same problem that has already find the solution?

Thanks!

#include <MKRGSM.h>
#include <avr/dtostrf.h>

//PIN number
int ThermistorPin = 1;
int Vo;
float R1 = 10000;
float logR2, R2, T, tc;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
int i;
char buff[10];
String valueString = "";

const char PINNUMBER[] = " ";
//APN data
const char GPRS_APN[] = "hologram";
const char GPRS_LOGIN[] = "";
const char GPRS_PASSWORD[] = "";
String HOLOGRAM_DEVICE_KEY = "";
String HOLOGRAM_MESSAGE = valueString;
String HOLOGRAM_TOPIC = "";

//initialize the library instance
GSMClient client;
GPRS gprs;
GSM gsmAccess;

//URL, path and port (e.g: example.org)
//Hologram's embedded API (https://hologram.io/docs/reference/cloud/embedded/) URL and port
char server[] = "cloudsocket.hologram.io";
int port = 9999;

void ntctemp()
{
  Vo = analogRead(ThermistorPin);
  R2 = R1 * (1023.0 / (float)Vo - 1.0);
  logR2 = log(R2);
  T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
  tc = T - 273.15;
}

void postingtemp()
{
  dtostrf(tc, 2, 6, buff);
  tc += 0.0;
  valueString += buff;
  valueString += ", ";
  Serial.print(valueString);
}

void setup() {
  // put your setup code here, to run once:
  //initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while(!Serial) {
    ;//wait for serial port to connect. Needed for native USB port only
  }

  Serial.println("Starting Arduino web client.");
  //connection state
  bool connected = false;
  //After starting the modem with GSM.begin()
  //attach the shield to the GPRS network with the APN, login and password
  while(!connected){
    if((gsmAccess.begin(PINNUMBER)==GSM_READY)&&
       (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY)){
        connected = true;
       } else {
        Serial.println("Not connected");
        delay(1000);
       }
  }

  Serial.println("Connecting...");
  
  ntctemp();

  //if you get a connection, report back via serial:
  if (client.connect(server, port)){
    Serial.println("connected");
    //Send message request:
    client.println("{\"k\":\"" + HOLOGRAM_DEVICE_KEY + "\",\"d\":\"" + HOLOGRAM_MESSAGE + "\",\"t\":\"" + HOLOGRAM_TOPIC + "\"}");
  } else {
    //if you didn't get a connection to the server:
    Serial.println("connection failed");
  }
}

void loop() {
  // put your main code here, to run repeatedly:
  //if there are incoming bytes available
  //from the server, read them and print them:
  if(client.available()) {
    char c = client.read();
    Serial.print(c);
    postingtemp();
    //valueString = client.write();
  }
  if(!client.available()&& !client.connected()){
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();

    //do nothing:
    for(;;)
    ;
  }
}

The problem is when I use the JSON String, it cannot read variable

What is it that can not read a variable?

You CAN construct a string, or String (ugh!), that contains the contents of a variable at the time the string was created. sprintf() populates a string. You're on your own to figure how to do that with a String.

PaulS:
You CAN construct a string, or String (ugh!), that contains the contents of a variable at the time the string was created.

Yes I can use a String and the program runs smoothly. The problem is on the dashboard where I receive errors stating that the Message body is required. When I use quotation marks for the string, I can receive the data however when I use variables, the dashboard doesn't receive anything except errors.

Is there anyone experiencing the same problem?