Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

WWWForm.data

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public var data: byte[];
public byte[] data;

Description

(Read Only) The raw data to pass as the POST request body when sending the form.

Usually, you just pass the WWWForm object directly to the WWW constructor, but you will need this variable if you want to change the request headers sent to the web server.

See Also: headers variable.

var form = new WWWForm();
form.AddField( "name", "value" );
var headers = form.headers;
var rawData = form.data;
var url = "www.myurl.com";

// Add a custom header to the request. // In this case a basic authentication to access a password protected resource. headers["Authorization"]="Basic " + System.Convert.ToBase64String( System.Text.Encoding.ASCII.GetBytes("username:password"));

// Post a request to an URL with our custom headers var www = new WWW(url, rawData, headers); yield www; //.. process results from WWW request here...
          WWWForm form = new WWWForm();
form.AddField( "name", "value" );
Hashtable headers = form.headers;
byte[] rawData = form.data;
string url = "www.myurl.com";

// Add a custom header to the request. // In this case a basic authentication to access a password protected resource. headers["Authorization"] = "Basic " + System.Convert.ToBase64String( System.Text.Encoding.ASCII.GetBytes("username:password"));

// Post a request to an URL with our custom headers WWW www = new WWW(url, rawData, headers); yield return www; //.. process results from WWW request here...