Get Page - Request Method PUT

PavelPavel Member Posts: 6 Contributor I
edited November 2018 in Help

There are two request methods in the Get Page operator - GET and POST. Is there a way to implement also PUT method?

 

If I manually change either GET or POST method to PUT in XML, the process fails: <parameter key="request_method" value="PUT"/>

 

 

Thanks!

Best Answers

  • IngoRMIngoRM Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Community Manager, RMResearcher, Member, University Professor Posts: 1,751 RM Founder
    Solution Accepted

    Hi,

     

    Not with the Get Page operator which - as you saw - only support Get and Post.

     

    But you could implement a put request with a command line tool for your OS which you invoke with the Execute Program operator.

     

    Hope this helps,

    Ingo

  • IngoRMIngoRM Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, Community Manager, RMResearcher, Member, University Professor Posts: 1,751 RM Founder
    Solution Accepted

    Even better - thanks for sharing!

    Best,

    Ingo

Answers

  • PavelPavel Member Posts: 6 Contributor I

    Ingo, thank you very much!

     

    Another way is to deploy the Execute Script operator. The example below works fine.

    -----------------------------------------------------------

    String json = %{query_string};
    String requestString = %{URL}

    //send request
    URL url = new URL(requestString);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setDoOutput(true);
    conn.setRequestMethod("PUT");
    conn.setRequestProperty("Content-Type", "application/json");
    OutputStream os = conn.getOutputStream();
    os.write(query_string.getBytes());
    os.flush();
    int responseCode = conn.getResponseCode();

    -----------------------------------------------------------

    Pavel

Sign In or Register to comment.