runemadsen / HTTP-Requests-for-Processing

http://www.runemadsen.com
MIT License
140 stars 39 forks source link

POST Body plain/text #44

Closed littledrumer closed 3 years ago

littledrumer commented 3 years ago

Is it possible to make a POST request with just plain text? I followed this link to allow for sending JSON and I tried adapting it so I could send text but it did not work.

I am trying to emulate this POST request from postman in Processing.

image

littledrumer commented 3 years ago

This actually does work once you follow the instructions here. For anyone else interested in sending plain text in the body of a POST message here is what I did.

Body is a string of data you want to send.

  PostRequest post = new PostRequest(APIurl);
  post.addHeader("Content-Type", "text/plain");
  post.addData(Body);
  post.send();
  println("Reponse Content: " + post.getContent());
  println("Reponse Content-Length Header: " + post.getHeader("Content-Length"));