# UnityWebRequest

> Creates a UnityWebRequest with the default options and no attached DownloadHandler or UploadHandler. Default method is GET.

## Definition

* **Type:** Constructor
* **Namespace:** [UnityEngine.Networking](/engine/6000.6/script-reference/unityengine/networking.md)
* **Assembly:** UnityEngine.UnityWebRequestModule

## UnityWebRequest()

Creates a UnityWebRequest with the default options and no attached [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md) or [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md). Default method is `GET`.

```csharp
public UnityWebRequest()
```

### Remarks

The raw constructor is useful for use cases which require detailed custom configuration of a [UnityWebRequest](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest.md). Most use cases will require the attachment of a [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md), an [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md) or both in order to function propertly.

Additional Resources: [UnityWebRequest.Get](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/get.md), [UnityWebRequest.GetTexture](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/gettexture.md), [UnityWebRequest.GetAudioClip](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getaudioclip.md), [UnityWebRequest.GetAssetBundle](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getassetbundle.md), [UnityWebRequest.Head](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/head.md), [UnityWebRequest.Post](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/post.md), [UnityWebRequest.Put](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/put.md), [UnityWebRequest.Delete](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/delete.md).

### Examples

```csharp
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class SimpleGetRequest : MonoBehaviour
{
    private const string Url = "https://jsonplaceholder.typicode.com/todos/1";

    void Start()
    {
        StartCoroutine(GetExample());
    }

    private IEnumerator GetExample()
    {
        // Use the constructor: UnityWebRequest(string url, string method)
        // Method can be UnityWebRequest.kHttpVerbGET, "GET", "POST", etc.
        using (UnityWebRequest request = new UnityWebRequest(Url, UnityWebRequest.kHttpVerbGET))
        {
            // Attach a download handler to receive body data
            request.downloadHandler = new DownloadHandlerBuffer();

            // Optionally set headers
            request.SetRequestHeader("Accept", "application/json");

            // Send the request and wait for completion
            yield return request.SendWebRequest();

            if (request.result != UnityWebRequest.Result.Success)
            {
                Debug.LogError($"Request failed: {request.error}");
            }
            else
            {
                // Access the response body
                string json = request.downloadHandler.text;
                Debug.Log($"Response Code: {request.responseCode}");
                Debug.Log($"Body: {json}");
            }
        }
    }
}
```

## UnityWebRequest(string)

Creates a UnityWebRequest with the default options and no attached [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md) or [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md). Default method is `GET`.

```csharp
public UnityWebRequest(string url)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The target URL with which this UnityWebRequest will communicate. Also accessible via the [UnityWebRequest.url](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/url.md) property.

### Remarks

The raw constructor is useful for use cases which require detailed custom configuration of a [UnityWebRequest](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest.md). Most use cases will require the attachment of a [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md), an [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md) or both in order to function propertly.

Additional Resources: [UnityWebRequest.Get](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/get.md), [UnityWebRequest.GetTexture](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/gettexture.md), [UnityWebRequest.GetAudioClip](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getaudioclip.md), [UnityWebRequest.GetAssetBundle](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getassetbundle.md), [UnityWebRequest.Head](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/head.md), [UnityWebRequest.Post](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/post.md), [UnityWebRequest.Put](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/put.md), [UnityWebRequest.Delete](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/delete.md).

### Examples

```csharp
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class SimpleGetRequest : MonoBehaviour
{
    private const string Url = "https://jsonplaceholder.typicode.com/todos/1";

    void Start()
    {
        StartCoroutine(GetExample());
    }

    private IEnumerator GetExample()
    {
        // Use the constructor: UnityWebRequest(string url, string method)
        // Method can be UnityWebRequest.kHttpVerbGET, "GET", "POST", etc.
        using (UnityWebRequest request = new UnityWebRequest(Url, UnityWebRequest.kHttpVerbGET))
        {
            // Attach a download handler to receive body data
            request.downloadHandler = new DownloadHandlerBuffer();

            // Optionally set headers
            request.SetRequestHeader("Accept", "application/json");

            // Send the request and wait for completion
            yield return request.SendWebRequest();

            if (request.result != UnityWebRequest.Result.Success)
            {
                Debug.LogError($"Request failed: {request.error}");
            }
            else
            {
                // Access the response body
                string json = request.downloadHandler.text;
                Debug.Log($"Response Code: {request.responseCode}");
                Debug.Log($"Body: {json}");
            }
        }
    }
}
```

## UnityWebRequest(Uri)

Creates a UnityWebRequest with the default options and no attached [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md) or [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md). Default method is `GET`.

```csharp
public UnityWebRequest(Uri uri)
```

### Parameters

**** (\[Uri]\(https\://learn.microsoft.com/dotnet/api/system.uri)): The target URI to which form data will be transmitted.

### Remarks

The raw constructor is useful for use cases which require detailed custom configuration of a [UnityWebRequest](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest.md). Most use cases will require the attachment of a [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md), an [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md) or both in order to function propertly.

Additional Resources: [UnityWebRequest.Get](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/get.md), [UnityWebRequest.GetTexture](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/gettexture.md), [UnityWebRequest.GetAudioClip](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getaudioclip.md), [UnityWebRequest.GetAssetBundle](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getassetbundle.md), [UnityWebRequest.Head](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/head.md), [UnityWebRequest.Post](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/post.md), [UnityWebRequest.Put](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/put.md), [UnityWebRequest.Delete](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/delete.md).

### Examples

```csharp
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class SimpleGetRequest : MonoBehaviour
{
    private const string Url = "https://jsonplaceholder.typicode.com/todos/1";

    void Start()
    {
        StartCoroutine(GetExample());
    }

    private IEnumerator GetExample()
    {
        // Use the constructor: UnityWebRequest(string url, string method)
        // Method can be UnityWebRequest.kHttpVerbGET, "GET", "POST", etc.
        using (UnityWebRequest request = new UnityWebRequest(Url, UnityWebRequest.kHttpVerbGET))
        {
            // Attach a download handler to receive body data
            request.downloadHandler = new DownloadHandlerBuffer();

            // Optionally set headers
            request.SetRequestHeader("Accept", "application/json");

            // Send the request and wait for completion
            yield return request.SendWebRequest();

            if (request.result != UnityWebRequest.Result.Success)
            {
                Debug.LogError($"Request failed: {request.error}");
            }
            else
            {
                // Access the response body
                string json = request.downloadHandler.text;
                Debug.Log($"Response Code: {request.responseCode}");
                Debug.Log($"Body: {json}");
            }
        }
    }
}
```

## UnityWebRequest(string, string)

Creates a UnityWebRequest with the default options and no attached [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md) or [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md). Default method is `GET`.

```csharp
public UnityWebRequest(string url, string method)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The target URL with which this UnityWebRequest will communicate. Also accessible via the [UnityWebRequest.url](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/url.md) property.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): HTTP GET, POST, etc. methods.

### Remarks

The raw constructor is useful for use cases which require detailed custom configuration of a [UnityWebRequest](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest.md). Most use cases will require the attachment of a [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md), an [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md) or both in order to function propertly.

Additional Resources: [UnityWebRequest.Get](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/get.md), [UnityWebRequest.GetTexture](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/gettexture.md), [UnityWebRequest.GetAudioClip](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getaudioclip.md), [UnityWebRequest.GetAssetBundle](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getassetbundle.md), [UnityWebRequest.Head](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/head.md), [UnityWebRequest.Post](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/post.md), [UnityWebRequest.Put](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/put.md), [UnityWebRequest.Delete](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/delete.md).

### Examples

```csharp
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class SimpleGetRequest : MonoBehaviour
{
    private const string Url = "https://jsonplaceholder.typicode.com/todos/1";

    void Start()
    {
        StartCoroutine(GetExample());
    }

    private IEnumerator GetExample()
    {
        // Use the constructor: UnityWebRequest(string url, string method)
        // Method can be UnityWebRequest.kHttpVerbGET, "GET", "POST", etc.
        using (UnityWebRequest request = new UnityWebRequest(Url, UnityWebRequest.kHttpVerbGET))
        {
            // Attach a download handler to receive body data
            request.downloadHandler = new DownloadHandlerBuffer();

            // Optionally set headers
            request.SetRequestHeader("Accept", "application/json");

            // Send the request and wait for completion
            yield return request.SendWebRequest();

            if (request.result != UnityWebRequest.Result.Success)
            {
                Debug.LogError($"Request failed: {request.error}");
            }
            else
            {
                // Access the response body
                string json = request.downloadHandler.text;
                Debug.Log($"Response Code: {request.responseCode}");
                Debug.Log($"Body: {json}");
            }
        }
    }
}
```

## UnityWebRequest(Uri, string)

Creates a UnityWebRequest with the default options and no attached [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md) or [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md). Default method is `GET`.

```csharp
public UnityWebRequest(Uri uri, string method)
```

### Parameters

**** (\[Uri]\(https\://learn.microsoft.com/dotnet/api/system.uri)): The target URI to which form data will be transmitted.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): HTTP GET, POST, etc. methods.

### Remarks

The raw constructor is useful for use cases which require detailed custom configuration of a [UnityWebRequest](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest.md). Most use cases will require the attachment of a [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md), an [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md) or both in order to function propertly.

Additional Resources: [UnityWebRequest.Get](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/get.md), [UnityWebRequest.GetTexture](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/gettexture.md), [UnityWebRequest.GetAudioClip](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getaudioclip.md), [UnityWebRequest.GetAssetBundle](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getassetbundle.md), [UnityWebRequest.Head](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/head.md), [UnityWebRequest.Post](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/post.md), [UnityWebRequest.Put](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/put.md), [UnityWebRequest.Delete](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/delete.md).

### Examples

```csharp
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class SimpleGetRequest : MonoBehaviour
{
    private const string Url = "https://jsonplaceholder.typicode.com/todos/1";

    void Start()
    {
        StartCoroutine(GetExample());
    }

    private IEnumerator GetExample()
    {
        // Use the constructor: UnityWebRequest(string url, string method)
        // Method can be UnityWebRequest.kHttpVerbGET, "GET", "POST", etc.
        using (UnityWebRequest request = new UnityWebRequest(Url, UnityWebRequest.kHttpVerbGET))
        {
            // Attach a download handler to receive body data
            request.downloadHandler = new DownloadHandlerBuffer();

            // Optionally set headers
            request.SetRequestHeader("Accept", "application/json");

            // Send the request and wait for completion
            yield return request.SendWebRequest();

            if (request.result != UnityWebRequest.Result.Success)
            {
                Debug.LogError($"Request failed: {request.error}");
            }
            else
            {
                // Access the response body
                string json = request.downloadHandler.text;
                Debug.Log($"Response Code: {request.responseCode}");
                Debug.Log($"Body: {json}");
            }
        }
    }
}
```

## UnityWebRequest(string, string, DownloadHandler, UploadHandler)

Creates a UnityWebRequest with the default options and no attached [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md) or [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md). Default method is `GET`.

```csharp
public UnityWebRequest(string url, string method, DownloadHandler downloadHandler, UploadHandler uploadHandler)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The target URL with which this UnityWebRequest will communicate. Also accessible via the [UnityWebRequest.url](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/url.md) property.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): HTTP GET, POST, etc. methods.**** (\[DownloadHandler]\(/engine/6000.6/script-reference/unityengine/networking/downloadhandler)): Replies from the server.**** (\[UploadHandler]\(/engine/6000.6/script-reference/unityengine/networking/uploadhandler)): Upload data to the server.

### Remarks

The raw constructor is useful for use cases which require detailed custom configuration of a [UnityWebRequest](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest.md). Most use cases will require the attachment of a [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md), an [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md) or both in order to function propertly.

Additional Resources: [UnityWebRequest.Get](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/get.md), [UnityWebRequest.GetTexture](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/gettexture.md), [UnityWebRequest.GetAudioClip](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getaudioclip.md), [UnityWebRequest.GetAssetBundle](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getassetbundle.md), [UnityWebRequest.Head](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/head.md), [UnityWebRequest.Post](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/post.md), [UnityWebRequest.Put](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/put.md), [UnityWebRequest.Delete](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/delete.md).

### Examples

```csharp
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class SimpleGetRequest : MonoBehaviour
{
    private const string Url = "https://jsonplaceholder.typicode.com/todos/1";

    void Start()
    {
        StartCoroutine(GetExample());
    }

    private IEnumerator GetExample()
    {
        // Use the constructor: UnityWebRequest(string url, string method)
        // Method can be UnityWebRequest.kHttpVerbGET, "GET", "POST", etc.
        using (UnityWebRequest request = new UnityWebRequest(Url, UnityWebRequest.kHttpVerbGET))
        {
            // Attach a download handler to receive body data
            request.downloadHandler = new DownloadHandlerBuffer();

            // Optionally set headers
            request.SetRequestHeader("Accept", "application/json");

            // Send the request and wait for completion
            yield return request.SendWebRequest();

            if (request.result != UnityWebRequest.Result.Success)
            {
                Debug.LogError($"Request failed: {request.error}");
            }
            else
            {
                // Access the response body
                string json = request.downloadHandler.text;
                Debug.Log($"Response Code: {request.responseCode}");
                Debug.Log($"Body: {json}");
            }
        }
    }
}
```

## UnityWebRequest(Uri, string, DownloadHandler, UploadHandler)

Creates a UnityWebRequest with the default options and no attached [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md) or [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md). Default method is `GET`.

```csharp
public UnityWebRequest(Uri uri, string method, DownloadHandler downloadHandler, UploadHandler uploadHandler)
```

### Parameters

**** (\[Uri]\(https\://learn.microsoft.com/dotnet/api/system.uri)): The target URI to which form data will be transmitted.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): HTTP GET, POST, etc. methods.**** (\[DownloadHandler]\(/engine/6000.6/script-reference/unityengine/networking/downloadhandler)): Replies from the server.**** (\[UploadHandler]\(/engine/6000.6/script-reference/unityengine/networking/uploadhandler)): Upload data to the server.

### Remarks

The raw constructor is useful for use cases which require detailed custom configuration of a [UnityWebRequest](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest.md). Most use cases will require the attachment of a [DownloadHandler](/engine/6000.6/script-reference/unityengine/networking/downloadhandler.md), an [UploadHandler](/engine/6000.6/script-reference/unityengine/networking/uploadhandler.md) or both in order to function propertly.

Additional Resources: [UnityWebRequest.Get](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/get.md), [UnityWebRequest.GetTexture](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/gettexture.md), [UnityWebRequest.GetAudioClip](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getaudioclip.md), [UnityWebRequest.GetAssetBundle](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/getassetbundle.md), [UnityWebRequest.Head](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/head.md), [UnityWebRequest.Post](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/post.md), [UnityWebRequest.Put](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/put.md), [UnityWebRequest.Delete](/engine/6000.6/script-reference/unityengine/networking/unitywebrequest/delete.md).

### Examples

```csharp
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class SimpleGetRequest : MonoBehaviour
{
    private const string Url = "https://jsonplaceholder.typicode.com/todos/1";

    void Start()
    {
        StartCoroutine(GetExample());
    }

    private IEnumerator GetExample()
    {
        // Use the constructor: UnityWebRequest(string url, string method)
        // Method can be UnityWebRequest.kHttpVerbGET, "GET", "POST", etc.
        using (UnityWebRequest request = new UnityWebRequest(Url, UnityWebRequest.kHttpVerbGET))
        {
            // Attach a download handler to receive body data
            request.downloadHandler = new DownloadHandlerBuffer();

            // Optionally set headers
            request.SetRequestHeader("Accept", "application/json");

            // Send the request and wait for completion
            yield return request.SendWebRequest();

            if (request.result != UnityWebRequest.Result.Success)
            {
                Debug.LogError($"Request failed: {request.error}");
            }
            else
            {
                // Access the response body
                string json = request.downloadHandler.text;
                Debug.Log($"Response Code: {request.responseCode}");
                Debug.Log($"Body: {json}");
            }
        }
    }
}
```
