how to do a web request unity

IEnumerator SendRequest(string url)
    {
        UnityWebRequest request = UnityWebRequest.Get(url);
        yield return request.SendWebRequest();

        if (request.isNetworkError || request.isHttpError)
        {
            Debug.LogError(string.Format("Error: {0}",request.error));
        }

        else
        {
            // Response can be accessed through: request.downloadHandler.text
            Debug.Log(request.downloadHandler.text);
        }
    }

4.17
6
Krish 100200 points

                                    // Call Method Through: StartCourotine(SendRequest());

IEnumerator SendRequest() 
{
	UnityWebRequest request = UnityWebRequest.Get("REQUEST_URL");
	yield return request.SendWebRequest();
 
	if(request.isNetworkError || request.isHttpError) {
      	// Error Occurred
		Debug.Log(request.error);
	}
	
  	else {
      	// Response can be accessed through: request.downloadHandler.text
		Debug.Log(request.downloadHandler.text);
	}
}

4.17 (6 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
unity open html from get request unity c# web requests get how to do a web request in unity is unity web request rest unity scripting web request unity www get request what is unity web request unity web request how to make server unity web request server put request unity web request unity web request get unity make web request unity web request tutorial web request unity UnityWebRequest tutoria unity api request unity send web request unityWebREquest get unity get url unity how to queue webrequests egt request unity request unity data unity pull html source unity web request unity api get fetch request in uniyuy unity get request json unityWebRequest get returned data unitywebrequest yield reutn unity get one string from responce unity webrequest get first 3 bytes from content get request unity c# unity use unitywebrequest unity get string[] from url unity webrequest get js web request in unity UnityWebRequest using unity get int from web link unity webrequest unity http get unity return webrequest result unity web request json unity web request get response unity http request get UnityWebRequest how to do a web request unity unitywebrequest get request unity how to get informatioon from a site with code getting data from unity webrequest how to use unity webrequest unity webrequest example make https get request unity get requests in unity unity rest GET how to do a http get request in unity webrequest unity c# how to send get request and return response in unity unity get request unity login api request received unity how to get API responce unity make http get request get request unity unity web request yield unity yield return for unitywebrequest unity web request example unity get webrequest success unity www.text unity web request unitywebrequest example unity html get request
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source