Can't post or patch records using nodejs

Using DreamFactory 2.14 (Bitnami image, EC2)
I had to upgrade the supplied nodejs from version 6 to the latest stable (version 10) to get a response from platform.api.get. But platform.api.post is still broken, as is platform.api.patch.
Like other users, I’m getting the feeling we’re on a sinking platform here, with bugs like this and with the silence in this forum.

More info:
which node
/opt/bitnami/nodejs/bin/node
node -v
v10.14.1

platform.api.post result: No record(s) detected.
A V8js pre-processing script on the table being posted to shows that event.payload is indeed empty.

platform.api.patch result: The request contains no valid record fields.

Sample code to reproduce:

options = {
‘headers’: {
‘X-DreamFactory-Api-Key’: platform.session.api_key,
‘X-DreamFactory-Session-Token’: platform.session.session_token,
‘Content-Type’: ‘application/json’
}
};

url = ‘http://localhost/api/v2/db/_table/table_name/’ + 1;

payload = {“field”: “value”};
platform.api.patch(url, payload, options, function(body, response) {
result = JSON.parse(body);
if (!result) {
console.log(body);
} else if (result.error) {
console.log(result.error.message);
} else {
console.log(‘internal URL updated 1 record’);
}
});

Hi @jps

I saw that you ran the which node command, and it brought back the correct nodejs path. Did you change your .env file to reflect the correct path?

CloudApp

Also you point out that you used a v8js script to test, but could you please try a node script as well? These are not the same engine and are not sourced via the same scripting paths.

Thanks!

Hi,

Regarding the path to node:
cat /opt/bitnami/apps/dreamfactory/htdocs/.env | grep NODE
DF_NODEJS_PATH=/opt/bitnami/nodejs/bin/node

which node
/opt/bitnami/nodejs/bin/node
They’re the same.

Regarding V8js: I think there is a misunderstanding here. We’re talking about two different tables, each with a script attached (pre-processing).

  • Table A has a nodejs preprocessing script, needed because of some special functionality for AWS that is not available in V8js. This is the only nodejs script in my solution. There are several problems with nodejs in DreamFactory, which is why I avoid it. Table A is posted to by the client software. The result should be something in AWS, a new record in table A and a patched record in table B.

  • The nodejs script attached to table A patches (or tries to patch) a record in table B as part of its preprocessing. The result is always : “The request contains no valid records”.

  • I put a V8js preprocessing script on table B to find out what is sent there by nodejs preprocessing from table A, for debugging purposes only. That script shows that the payload indeed arrives there empty.

In short, I have not been able to PATCH or POST records successfully from nodejs v10. The original nodejs supplied in the Bitnami image is v6, that one does not do GET either (platform.api.xxx starts and returns nothing), v10 at least manages GET, but not POST or PATCH.

Aha, thanks for the clarification, @jps. Looking into this further now. Thanks for confirming your Node path as well.

I’m trying to do the same and get stuck: when i do the patch through APIDocs, it work well, but when i try patch inside a server-side script, it returns:

{“error”:{“code”:400,“context”:null,“message”:“The request contains no valid record fields.”,“status_code”:400}}

I set a var_dump of the request on the pre-patch event and when i run the patch from the APIDocs, it shows the payload, but when i run from the script, it shows nothing inside the payload… what should be happening?

Any thoughs? thanks in advance.

is there, nowadays, any way to solve this issue, Erik? or nodejs in DF 2.14 is still broken? i coudn’t do a patch either…