I am trying to add a Multipart form data section to UnityWebRequest that contains a key whose value is an integer. Below is my code for the same:
List<IMultipartFormSection> formData = new List<IMultipartFormSection>();
formData.Add(new MultipartFormDataSection("uploadType", 5));
But this is throwing an error saying cannot convert from int to byte[]. I checked the API spec for MultipartFormDataSection and it accepts (string, byte[]) only.
Is there a way I can attach an int value instead of a byte array in the same?
The second argument for MultipartFormDataSection
takes string or byte array. Just convert the int
you want to send to string
then pass it to MultipartFormDataSection
data argument.
formData.Add(new MultipartFormDataSection("uploadType", Convert.ToString(5)));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.