Using Header and BasicHeader with HttpUrlConnection in android -


in android 6.0 org.apache.http.legacy library deprecated, try migrate project use httpurlconnection. in project, used header , basicheader. didn't found how can replace these classes httpurlconnection. want know how can add header in request using httpurlconnection.


  url url=new url("yoururl");   httpurlconnection connection= (httpurlconnection) url.openconnection();//establishing connection url   connection.setdooutput(true);   connection.setrequestmethod("post");//method type   connection.setrequestproperty("content-type","application/json");// setting headers 

Comments

Popular posts from this blog

javascript - How do you prevent nested queries/catches in sequelize? -

java - Could not retrieve pre-bound Hibernate session - Could not obtain transaction-synchronized Session for current thread -

java - ConcurrentModificationException upon committing transaction with Hibernate -