0

In android 6.0 the org.apache.http.legacy library is deprecated, so i try to migrate a project to use HttpURLConnection. In the project, i used the Header and the BasicHeader. I didn't found how i can replace these classes with HttpUrlConnection. I want just to know how can i add a header in a request using HttpUrlConnection.


1 Answer 1

2
 URL url=new URL("YOURURL"); HttpURLConnection connection= (HttpURLConnection) url.openConnection();//establishing connection from url connection.setDoOutput(true); connection.setRequestMethod("POST");//method type connection.setRequestProperty("Content-Type","application/json");// setting headers 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.