Loading...
Logo
Processing Forum
So, I'm using the code from  this forum post (the last post) to post data for an API, but I can't figure out how to deal with the response. The response is an HttpEntity, and the code the other forum post used just printed it, but I want it to be parsed into an XMLElement.
Apparently the entity can be written to an output stream, but I don't really know what that is and really think that I am in over my head here.
Help would be much appreciated.

Replies(5)

The message you refer to uses the Apache library. You can also do that in pure Java.
For example, in http://bazaar.launchpad.net/~philho/+junk/Processing/files/head:/ImageUpload/ I shown (in DataUpload.java) how to post a file (an image), and get the response from the server, without additional library.
That is helpful, and thank you for both of your quick responses. However, I can't find any information on how to use the DataUpload class to post name-value pairs. I found  this, but that doesn't seem to be the same, or maybe I'm missing something. Perhaps you could point me towards a website, or tell me yourself?
I also want to say thank you for being such a good help to me and everybody else.
The problem is that you are not precise. Is the API really using POST or is it using GET (more suited to send name-value pairs, unless it has side effects)? You can send name-value pairs with POST too, of course.
DataUpload is my class, if you must look up something, it would be the Java classes it uses internally, like HttpURLConnection .
Sorry, somehow I missed the DataUpload class. What I wanted to be able to do is use POST to send name-value pairs. The reason the API uses post is because there is a lot of data being sent in those pairs, I think.
But, I did get it to work using HttpURLConnection.