Hi, we need to make SmartClient client to talk with a REST service.
This service expect that we use HTTPMethod = "PATCH".
Ok, we followed the documentation (https://smartclient.com/smartclient-...pe..DSProtocol) that say this:
So far so good.
SmartClient allowed us to change the DSRequest.httpMethod to "PATCH" (or anything else),
And the way the params will be sent to the service, is decided by the dataProtocol, in this case it is set to "postParams".
The code is this:
But the params are never sent in the server body, like a HTML form would.
It only work when the httpMethod = "PUT".
Am I using the dataProtocol = "postParams" right?
This service expect that we use HTTPMethod = "PATCH".
Ok, we followed the documentation (https://smartclient.com/smartclient-...pe..DSProtocol) that say this:
Code:
If you are integrating with a REST server that requires the more obscure RPCRequest.httpMethods of "PUT", "DELETE" or "HEAD", you can specify these httpMethod settings via OperationBinding.requestProperties. dataProtocol settings that mention "GET" or "POST" are compatible with these additional HTTP methods as well. Typical operationBindings for a REST server that uses "PUT" and "DELETE" are as follows: 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.
SmartClient allowed us to change the DSRequest.httpMethod to "PATCH" (or anything else),
And the way the params will be sent to the service, is decided by the dataProtocol, in this case it is set to "postParams".
The code is this:
Code:
transformRequest = function (dsRequest) { if (dsRequest.operationType === "update") { dsRequest.httpMethod = "PATCH"; dsRequest.dataProtocol = "postParams"; dsRequest.actionURL = "http://url_of_the_rest_service/service_name; return {a_field_name: "a value"}; }else { return dsRequest.data; } }
It only work when the httpMethod = "PUT".
Am I using the dataProtocol = "postParams" right?
Comment