I’m struggling with getting my platform.api.patch script working. When trying it in API docs, it’s working:
I’m using: updateRecordsByFilter() - Update (patch) one or more records
Table_name = Status
body = {“Status_status”:“new”,“Status_approver”:“Johny”}
filter = Status_TT = ‘12345’
With this it should update the items with Status_TT = 12345 with the information in the body. As i said, it works.
When trying to make this server side, i’ve tried many things and the closest i get is:
var queryupdate = '{"Status_status":"new","Status_approver":"Johny"}';
var string3 = JSON.parse(queryupdate);
platform.api.patch("db/status?filter=Status_TT = '12345' ", string3);
The problem is that it updates all the records in that table, including the ones thatdon’t have 12345 under Status_TT
It’s probably something very simple and would appreciate if someone could help me with some code examples, i can work out the rest how to apply it to my project
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?
Hi, when i use what u wrote (assuming the method is: platform.api.patch(url, payload)) it returns: {"error":{"message":"callback is not a function","code":500}}. Is there any other thing to consider?
First of all we only use POST type of requests that trigger a server side script. We never PATCH the DB directly. If that is what you’re doing, meaning using the API directly to patch… I would need to test if that works as well.
Second, if you would be OK to do a POST to a server side custom script and inside that server side script you patch what you need to patch it works as I suggested, at least for us.
oh, ur code is about the calling from the client, right? the code i posted is from de server side script. are we talking about the same? thanks for the reply.