The WWWForm requires a AddField(parameter name, value). Right now, I am trying to interface a web API that just expects XML to be posted to it. Is there a way to just post xml data from Unity without explicitly binding it to an AddField parameter?
2 Answers
2Use the WWW constructor that takes plain bytes of postData, rather than taking a WWWForm.
Yes you can, just don’t use WWWForm because it’s designed to represent a web-formular and therefore only contains fields.
If you read the documentation of WWW carefully you will find multiple constructors. There are two that accept a byte array as raw-post data.
how do you convert a string or char array to a byte array... i tried string.ToCharArray() - but unity 3.4 has issues taking char arrays as byte arrays "The type 'UnityEngine.WWW' does not have a visible constructor that matches the argument list '(String, char[])'."
– inaThat might help: http://www.java2s.com/Code/CSharp/Development-Class/ConvertbytearraytoStringwithBitConverter.htm googled in less than 5 Sec.
– Bunny83
how do you convert a string or char array to a byte array... i tried string.ToCharArray() - but unity 3.4 has issues taking char arrays as byte arrays "The type 'UnityEngine.WWW' does not have a visible constructor that matches the argument list '(String, char[])'."
– ina