How to send XML data to a Rapidminer Service through a POST REST API call

KostasBonikosKostasBonikos Member Posts: 25 Maven
edited November 2018 in Knowledge Base

This article deals with XML files.


For a CSV upload, please see:





When we want to sent a whole list of records as a file or as raw XML data to the server to get scored, or for training; we need a POST call.


Before we get started on this, it may be a bit daunting finding out how to do a POST call because it is not as simple as passing a single value through a web browser and a lot of articles out there approach making POST calls through programming languages. We will use cURL, a command line tool for sending and receiving files through URL syntax. It has many parameters but we only need two for now, further details can be found by typing "curl -h" in the command line or through https://en.wikipedia.org/wiki/CURL


Let us get started with a very simple process which trains a decision tree to classify customers. It is meant to be able to predict the "Response" attribute.


daily demo.png  

A sample of the data is as follows:

daily demo data.png


For deployment, we have a process which imports the model built above on the data we have with known responses and applies it to data with unknown responses.


In XML, the scoring data looks different. Before uploading an XML file to a service, it is best to open that file in Studio first, in order to configure the "Read XML" operator so that it can parse the XML it later.

1 deployment process XML.png

This is best done by using the import configuration wizard that can be seen below.


0 XML Load.png


Once the data is loaded, there should be an "xpath for examples" value and "xpaths for attributes" should also be filled in automatically to look like below:

Names often will not have spaces and that is the reason they will not match the data the model was trained on, we will be fixing this in the next step.


2 XML enumeration.png

 By clicking on the "data set meta data information", the following dialogue will appear and the attribute names can be amended there to match the names used to train the predictive model in the training process.


3 XML meta data info.png


We can then connect the "Read XML" operator to the process area input node. This is so that it can receive data through the POST upload from the service we are going to create. This operator is not pointed to any file any more but will score what is passed to the service.


1 deployment process XML.png

Before we create the service, bear in mind that the data we are going to pass for scoring does not have values in the response attribute, those values are going to be predicted.


daily demo data no response.png


Let us now create the service in Rapidminer Server:


create service.png  

There are no special parameters or macros, as long as it points to the correct process for deployment. We then test the service to get the URL which, in this case, is:



We can use curl from the command line, which in Windows can be started from the Start menu by typing "cmd" and then we can enter the follwoing curl command:


curl --user admin --upload-file C:\test.xml http://<your server>:8080/api/rest/process/POSTtest?


Or,  curl --user admin --data  <XML data> http://<your server>:8080/api/rest/process/POSTtest? 


The user in this case is "admin" and the file is test.xml and is saved in the C: drive, the path for the file can change. When this is executed, you will be asked for your password for the user and then you should get a list of scored records in XML in this case, this depends on the output format chosen when defining the service.



With the above help, you should be able to create a process and expose it as a service in Rapidminer Server and then test that is is able to receive raw data or files through a POST upload and score and return the output.



Sign In or Register to comment.