I had already posted this question a couple of months ago, in the meantime I tried different approaches also with the help of the very collaborative developers at online-convert.com but always with the same result, i.e. nothing.
This is my problem. I need to convert images from one format to a different one using an online service (https://www.online-convert.com/, there are many others but this seems to be the most professional). Before trying to access the conversion application I need to know which server to use for server load balancing reasons. According to their website I have to make a XML request as follows:
<?xml version="1.0" encoding="utf-8"?>
<queue>
<apiKey>2e3152........03258494237510e6</apiKey>
<targetType>image</targetType>
</queue>
and the answer should look like this
<?xml version="1.0" encoding="utf-8"?>
<queue-answer>
<status>
200
<message>Found free slot on server.</message>
</status>
<params>
<server>http://www18.online-convert.com</server>
</params>
</queue-answer>
To use this service from Servoy I have written this simple method, using a POST request. This is what they recommend
It is important that the data is sent via POST inside the POST variable named “queue”. In other words, the XML must be sent like a form variable named queue
.
var xmlfile = '<?xml version="1.0" encoding="utf-8"'?><queue><apiKey>8703ce0ed6dfb9c06nhybe5f65c841f1</apiKey><targetType>image</targetType></queue>';
var client = plugins.http.createNewHttpClient();
var poster = client.createPostRequest('http://api.online-convert.com/get-queue');
var head = poster.addHeader('Content-type', 'multipart/form-data');
poster.addParameter('queue',xmlfile);
var response = poster.executeRequest();
var httpBody = response.getResponseBody();
I tried also a GET request, and every permutation of the POST request such as addFile and so on. But I always receive an error message saying
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<queue-answer>
<status>
8
<message>The XML file is empty. Please verify that you have send us a variable \"queue\" filled with the XML data.</message>
</status>
</queue-answer>
Any idea on where I am wrong? I really need your help to sort this out. It doesn’t seem too complicate, so imagine it is just a trcky issue but I cannot see it.