No announcement yet.
  • Filter
  • Time
Clear All
new posts

    DSRequest.dataProtocol: "postParams" for HTTPMethod other than "POST"

    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 ( that say this:
    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:
           {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
    "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.
    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:
    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 {
    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?

    We've have addressed this issue and you will see it fixed as of tomorrow's builds, July 5.

    Isomorphic Software