HTTP integration question

Hello everyone,
I’m trying to send a string from a Lopy to my TTN application, and it works fine, I can see it arrives in my console in bytes. Then, as I want to save it in my database I’m using the HTTP integration to send it to my server. I did manage to store int data from the JSON, but when it comes to storing string I get nothing… Here is the JSON I receive :
“app_id”: “elliptika”,
“dev_id”: “lopy4_receiver”,
“hardware_serial”: “70B3D5499AB9C167”,
“port”: 2,
“counter”: 67,
“payload_raw”: “SGVsbG8gd29ybGQ=”,
“metadata”: {
“time”: “2019-09-26T13:30:22.205058336Z”,
“frequency”: 868.1,
“modulation”: “LORA”,
“data_rate”: “SF7BW125”,
“coding_rate”: “4/5”,
“gateways”: [
“gtw_id”: “eui-30aea4fffeeca85c”,
“timestamp”: 1684920418,
“time”: “2019-09-26T13:30:21.548157Z”,
“channel”: 0,
“rssi”: -30,
“snr”: 7,
“rf_chain”: 0,
“latitude”: 48.422424,
“longitude”: -4.463054,
“location_source”: “registry”
“downlink_url”: “
If I try to store “app_id” or even “payload_raw” it doesn’t work. Here is a look at my php code to receive the JSON data with my attempt to decode it :
$donnees = trim(file_get_contents(‘php://input’)); //<-- will capture all posted data
$data = json_decode($donnees,True);
$parametre_counter = $data[‘counter’];
$parametre_payload = base64_decode($data[‘payload_raw’]);

Am I doing something dumb or am I forgetting something maybe ?
Thanks in advance :slight_smile:

what do you see when do a var dump on $data?

Weird thing is that if I do a var_dump as you suggest it tells me that $data is NULL… but if I replace $data[‘payload_raw’] by $data[‘counter’] it registers well in my DB. I am quite lost right now

The problem seems to come from my php request to write in my DB, because even if I create a new string variable and try to register it in my database nothing happens. In my DB “message” is a varchar of 255

Once you come to know a solution please share it here as it could be of some help.

It was a question of single quotes in the query !
Here is the forum where I found the answer :

So the working querry is :
$requete = “INSERT INTO theThingsNetwork (message,counter) VALUES (’$parametre_payload’,’$parametre_counter’)”;

glad it’s working! Make sure to escape those values using PDO, don’t trust the internet :slight_smile: