dreamfactory php脚本pre_process有效负载修改一个资源字段

时间:2019-01-03 07:11:57

标签: php arrays payload dreamfactory

在发布请求中的Dreamfactory rest API中,我收到这样的有效负载:

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

在将其插入mysql数据库之前,如何仅引用字段“ Gas”将其修改为“ 00000”? 这是我编写的脚本,但是在执行发布请求时收到以下错误:

<?php

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

?>

错误是:

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

0 个答案:

没有答案