Pentaho

 View Only
Expand all | Collapse all

Pentaho Rest Client: need to upload a json body with DELETE method

This thread has been viewed 32 times
  • 1.  Pentaho Rest Client: need to upload a json body with DELETE method

    Posted 11-17-2021 10:30
    Hi, pentaho spoon 9.1 / 9.2 user here.
    I have this API that ask me to send a json during a DELETE method call do delete some entry.
    This is the API documentation:

    DELETE /:resource_type/:resource_id/relationships/attachments

    Delete multiple attachments.

    Deletes one or more specified attachments. Returns the deleted attachments and a 200 status code if successful.

    Below is a sample request body with a JSON array to delete multiple objects:

    "data": [
      {
        "type": "attachments",
        "attributes": {
          "id": 2
        }
      },
      {
        "type": "attachments",
        "attributes": {
          "id": 4
        }
      }
    ]
    But in Pentaho REST client step the body option is grayed out for the DELETE method:



    How can I upload a json (I've made it using a Javascript Step) in the body field using the rest client with the DELETE method?
    Thanks a lot

    ------------------------------
    Federico Boldori
    Systems Engineer
    Monitoro sRL
    ------------------------------


  • 2.  RE: Pentaho Rest Client: need to upload a json body with DELETE method

    Posted 11-17-2021 19:33

    Hi Federico.    The standard for a DELETE request is that there is no body (or the body is ignored).  Though you could implement something if you wanted.   I'd suggested using a curl request like this:

    curl -X DELETE https://reqbin.com/sample/delete/json -H "Accept: */*" -H "Authorization: Bearer mt0dgHmLJMVQhvjpNXDyA83vA_PxH23Y" -H "Content-Type: application/json" --data-binary @- <<DATA
    {"data": [ { "type": "attachments", "attributes": { "id": 2 } }, { "type": "attachments", "attributes": { "id": 4 } } ]}
    DATA

    and pass the parameters into a job with a 'shell' entry or in a transform use an ssh step to login into your local OS and run the curl statement.



    ------------------------------
    Andrew Cave
    Systems Engineer
    BizCubed Pty Ltd
    ------------------------------



  • 3.  RE: Pentaho Rest Client: need to upload a json body with DELETE method

    Posted 11-18-2021 02:59
    Hi Andrew, thank you so much for the response and the solution! I will try it!

    For the standard, maybe I should open a ticket to the developers.
    As for RFC7231, a body in a delete request is permitted. And in the Pentaho Wiki per for the REST client step is allowed, but the forms stay grayed out. (Link)



    EDIT:
    I've created a bug report on Jira DELETE method in REST Client does not allow Body (options grayed out)
    Pentaho remove preview
    DELETE method in REST Client does not allow Body (options grayed out)
    Open Rest Client Step in a transformation Select DELETE method The body field becomes grayed out in the step configurations page.
    View this on Pentaho >


    ------------------------------
    Federico Boldori
    Systems Engineer
    Monitoro sRL
    ------------------------------