Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

What's wrong with UnityWebRequest.Post()

Discussion in 'Connected Games' started by SamTyurenkov, Dec 3, 2019 at 1:04 AM.

  1. SamTyurenkov

    SamTyurenkov

    Joined:
    May 12, 2018
    Posts:
    24
    First of all VS says it doesn't have a Post type, and underlines it:



    Second thing, according to manual, you have to use method as a parameter, and you have to use download and upload handlers:
    https://docs.unity3d.com/2020.1/Documentation/ScriptReference/Networking.UnityWebRequest-ctor.html

    Third thing, all the other docs and answers around still use it as .Post().

    Can someone tell me a correct up to date alternative to that:

    Code (CSharp):
    1. UnityWebRequest www = new UnityWebRequest.Post("http://url.com", formData);
    with those download and uploadhandlers
    Code (CSharp):
    1. public UnityWebRequest(Uri uri, string method, Networking.DownloadHandler downloadHandler, Networking.UploadHandler uploadHandler);
    Thanks!
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    2,351
    UnityWebRequest.Post() is a static method, don't put new before it.
     
    SamTyurenkov likes this.