Dreamfactory php script pre_process payload modify one resource field


#1

In Dreamfactory rest API if I receive with a post request a payload like this :

{"resource": [{"Time":"2018-12-21T07:49:23","Gas":"111111","Pressure":"1111","Temperature":"11111"}]}

how can I refer only to field “Gas” to modify it into “00000” before insert it into mysql database ? This is the script that I write but I recive the below error when I do a post request:

<?php
$event['request']['payload']['resource']['Gas']="00000";
$event['request']['content']=json_encode($event['request']['payload']);
?>

the error is:

{"error":{"code":1000,"context":{"error":["Gas"],"resource":{"0":{"messageID":32},"Gas":{"code":500,"message":"array_merge(): Argument #1 is not an array"}}},"message":"Batch Error: Not all requested records could be created.","status_code":500}}

#2

In all of these four files of my docker container

opt/bitnami/dreamfactory/.env-dist
opt/bitnami/dreamfactory/vendor/dreamfactory/df-core/config/df.php
opt/bitnami/dreamfactory/installer.sh
bitnami/dreamfactory/.env

I have modifed:

DF_ALWAYS_WRAP_RESOURCES=true 

with

DF_ALWAYS_WRAP_RESOURCES=false

but when I try to make a post to my rest api with fiddler with a payload like this:

{"Time":"2018-12-21T07:49:23","BME680":{"Temperature":20.3,"Humidity":41.8,"Pressure":1021.1,"Gas":286.65}}

I recevie always the same error:

{"error":{"code":400,"context":null,"message":"No record(s) detected in request. Please make sure record(s) are wrapped in a 'resource' tag. Example: {&quot;resource&quot;:[{&quot;record&quot;:1},{&quot;record&quot;:2}]}","status_code":400}}

Please could someone help me ?