Hi, I am trying to integrate SmartClient DataSource with PostREST (https://postgrest.org/).
Using transformRequest we made it work for "fetch" operations.
So far, so good. In fact it's really good, because once the
is set, SmartClient handle everything. ;)
Reading the documentation (https://smartclient.com/smartclient-...pe..DSProtocol) we got this nice example:
Now we have to make it work with httpMethod:PUT for "update" operations, but then there's a catch.
The REST is expecting that, some parameters will be send in the URL (like getParams), and other parameters must be sent in the body (like postParams).
Like this (https://postgrest.org/en/v12/referen...ws.html#update):
How should we proceed?
Is there a way to inject the json data in the body, or to change the dataURL, from inside the transformRequest method?
Thank you for any help.
By the way, we're using v12.1p_2024-03-19/PowerEdition
Using transformRequest we made it work for "fetch" operations.
So far, so good. In fact it's really good, because once the
Code:
DataSource.dataFormat: "json"
Reading the documentation (https://smartclient.com/smartclient-...pe..DSProtocol) we got this nice example:
Code:
operationBindings:[ {operationType:"fetch", dataProtocol:"getParams"}, {operationType:"add", dataProtocol:"postParams"}, {operationType:"remove", dataProtocol:"getParams", requestProperties:{httpMethod:"DELETE"}}, {operationType:"update", dataProtocol:"postParams", requestProperties:{httpMethod:"PUT"}} ], Valid values: "getParams" Data is added to the dataURL, with each property in the data becoming an HTTP parameter, eg http://service.com/search?keyword=foo "postParams" Data is POST'd to the dataURL, with each property becoming an HTTP parameter, exactly as an HTML form would submit them if it had one input field per property in the data.
The REST is expecting that, some parameters will be send in the URL (like getParams), and other parameters must be sent in the body (like postParams).
Like this (https://postgrest.org/en/v12/referen...ws.html#update):
Code:
curl "http://localhost/employees?id=eq.4" \ -X PUT -H "Content-Type: application/json" \ -d '{ "id": 4, "name": "Sara B.", "salary": 60000 }'
Is there a way to inject the json data in the body, or to change the dataURL, from inside the transformRequest method?
Thank you for any help.
By the way, we're using v12.1p_2024-03-19/PowerEdition
Comment