The Method Setrequestproperty(string, String) In The Type Urlconnection Is Not Applicable For The Arguments (string, Arraylist)
Solution 1:
You can send String parameter as both field with setRequestProperty()
Problem : In second parameter, you are passing ArrayList<String>
Try to pass every element of multimgss one by one with setRequestProperty()
FileInputStreamfileInputStream=newFileInputStream(sourceFile);
URLurl=newURL(upLoadServerUri);
// Open a HTTP connection to the URL
conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true); // Allow Inputs
conn.setDoOutput(true); // Allow Outputs
conn.setUseCaches(false); // Don't use a Cached Copy
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection", "Keep-Alive");
conn.setRequestProperty("ENCTYPE", "multipart/form-data");
conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + boundary);
conn.setRequestProperty("name", pname);
conn.setRequestProperty("categoryid", catsids);
conn.setRequestProperty("skucode", pskucode);
conn.setRequestProperty("sale_rate", psalerate);
conn.setRequestProperty("purchase_rate", ppurchaserate);
conn.setRequestProperty("weight", pweight);
conn.setRequestProperty("weighttype", pweighttype);
conn.setRequestProperty("description", pdesc);
conn.setRequestProperty("image", multimgss.get(i++));
// it will give i th element Note : From Android Developer documentation for setRequestProperty()
Sets the value of the specified request header field. The value will only be used by the current URLConnection instance. This method can only be called before the connection is established.
So, you need to call this method everytime before establishing connection
Solution 2:
setRequestProperty method only accept String instead of ArrayList . get JSONArray from ArrayList as:
JSONArray jsonArrayImgs=newJSONArray();
ArrayList<String> multimgss=newArrayList<String>();
for (Stringstring : multimgss)
{
jsonArrayImgs.put(string);
}
Now pass jsonArrayImgs to setRequestProperty :
conn.setRequestProperty("image", jsonArrayImgs.toString());
EDIT:
sourceFileUri is null . so update getItem method as of Adapter:
public String getItem(int position) {
return arrayList.get[position];
}
now inside onItemClick of GridView asign selected image path to sourceFileUri as:
publicvoidonItemClick(AdapterView<?> parent,
View v, int position, long id){
imagepath=objImageAdapter.getItem(position);
}
Post a Comment for "The Method Setrequestproperty(string, String) In The Type Urlconnection Is Not Applicable For The Arguments (string, Arraylist)"