I have an issue while using multipart to upload post data to server.
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(10000);
conn.setConnectTimeout(15000);
conn.setRequestMethod("POST");
conn.setUseCaches(false);
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestProperty("Connection", "Keep-Alive");
conn.addRequestProperty("Content-length", reqEntity.getContentLength() +"");
conn.addRequestProperty(reqEntity.getContentType().getName(),reqEntity.getContentType().getValue());
This thing works fine when I use the following in the build.gradel
android {
compileSdkVersion 22
buildToolsVersion "23.0.2"
//useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.valuelabs.fup"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
when the target version is changed to 23 and compileSdkVersion is changed to 23 which is the latest,
conn.addRequestProperty(reqEntity.getContentType().getName(),reqEntity.getContentType().getValue());
This line is throwing error saying getName and getValue methods are not found,
How should i solve this issue, what are the alternate methods to these methods. Any help is greatly appreciated. Thanks in advance.