user41133: I want to post data that I'm getting from the sensor every 5 seconds to my application in JSON format. Initially, I'm getting data as int and converting into String.
For example:
if data=15, it is converting into string.
String st=String(data);

Now I want to post st every 5 seconds.
    int S2 = http.sendRequest("PUT", "{\"itemId\":\"64006A962B71A1E7B3A0428637DA997C.327681\",\"item\":{\"Properties\":{\"AssetSensorDistance\":\"+st+\"}},\"operationType\":\"Update\",\"originalItem\":{\"Work_Order\":{\"ItemId\":\"64006A962B71A1E7B3A0428637DA997C.327681\"},\"Properties\":{\"AssetSensorDistance\":\"+st1+\"}}}");
    Serial.print("Sensor Status: ");
    Serial.println(S2);

st1 is the previous value, it is printing httpcode -2(invalid Syntax).
Can anyone help me with this issue?
Thanks in advance.

user7508: The string
"{\"AssetSensorDistance\":\"+st+\"}"

contains a literal "+st+". If you want to do string concatenation, you
should terminate the string with a double quote character, then add st,
then use another double quote to start the second part of the string:
"{\"AssetSensorDistance\":\""+st+"\"}"


41133: <p>I want to post data that I'm getting from the sensor every 5 seconds to my application in JSON format. Initially, I'm getting data as int and converting into String.</p>

<p>For example:</p>

<p>if data=15, it is converting into string.</p>

<pre><code>String st=String(data);
</code></pre>

<p>Now I want to post <code>st</code> every 5 seconds.</p>

<pre><code>    int S2 = http.sendRequest("PUT", "{\"itemId\":\"64006A962B71A1E7B3A0428637DA997C.327681\",\"item\":{\"Properties\":{\"AssetSensorDistance\":\"+st+\"}},\"operationType\":\"Update\",\"originalItem\":{\"Work_Order\":{\"ItemId\":\"64006A962B71A1E7B3A0428637DA997C.327681\"},\"Properties\":{\"AssetSensorDistance\":\"+st1+\"}}}");
    Serial.print("Sensor Status: ");
    Serial.println(S2);
</code></pre>

<p>st1 is the previous value, it is printing httpcode -2(invalid Syntax).</p>

<p>Can anyone help me with this issue?</p>

<p>Thanks in advance.</p>
 7508: <p>The string</p>



<pre class="lang-c++ prettyprint-override"><code>"{\"AssetSensorDistance\":\"+st+\"}"
</code></pre>

<p>contains a literal "+st+". If you want to do string concatenation, you
should terminate the string with a double quote character, then add st,
then use another double quote to start the second part of the string:</p>

<pre class="lang-c++ prettyprint-override"><code>"{\"AssetSensorDistance\":\""+st+"\"}"
</code></pre>
