Quantcast
Channel: DreamFactory Forum - Latest topics
Viewing all articles
Browse latest Browse all 1524

Dreamfactory php script pre_process payload modify one resource field

$
0
0

@luca wrote:

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}}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 1524