0

1) How can I send specific request headers whilst a url.openConnection()?

2) Also, how can I, in addition, turn the request to a POST and send post data as well?

3) What document would you recommend to learn further more about url.openConnection() and its possibilities?

Thank you.

1

1 Answer 1

2
  1. connection.addRequestProperty(headerName, headerValue);

  2. You should call connection.setRequestMethod("POST");, then call connection.getOutputStream() and write to this stream content of POST request.

  3. google: "java http post example" brings tons of documentation. Here is the first one: http://www.exampledepot.com/egs/java.net/post.html

Sign up to request clarification or add additional context in comments.

1 Comment

Hello, thank you. However, the most important part is missing. How do I select the IP address FROM which this request will be fired? Server has multiple IP addresses bind to it, multiple interfaces. I want to use a specific one for this request. I would really appreciate your help, thank you VERY MUCH!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.