Pentaho

 View Only
  • 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
    ------------------------------



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

    Posted 12-03-2021 01:04
    DELETE method fails when using an authenticated service (401) if Body field is left empty / not supplied, because then the Authorization header is not being send along.
    The DELETE method shouldn't require a body to be supplied.
    I mentioned before that I tried setting an empty JSON body like "{}" as input for the "Body field" just to test if this would solve my issue. I must have done this test wrong somehow back then because I tried doing this again just now (triggered by the example transformation attached by Andrei) and now the DELETE is executed OK / without error (no 401 anymore).

    ------------------------------
    martin johny
    Brand Manager II
    Bosco

    UPSers
    ------------------------------



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

    Posted 12-03-2021 02:52
    Hi Martin,
    yes but my problem is that i cannot select a field for the body when the method is DELETE (in my script is 'campo corpo', that means body)
    The delete method by RFC could be used with a body.



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



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

    Posted 12-11-2021 00:15
    The DELETE method shouldn't require a body to be supplied. I mentioned before that I tried setting an empty JSON body like "{}" as input for the "Body field" just to test if this would solve my issue. I must have done this test wrong somehow back then because I tried doing this again just now (triggered by the example transformation attached by Andrei) and now the DELETE is executed OK / without error (no 401 anymore). AdvancedMD Login

    ------------------------------
    Kenneth Adams
    Product Manager
    Company
    ------------------------------



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

    Posted 12-13-2021 02:55
    Hi Kenneth,
    but what version of Spoon are you using?

    My problem is when i select the DELETE method the "Body Field" becomes grayed out, so i cannot even send an empty Json.

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