'Unity: sending a post request where it's data contains list
I want to send a post request with a list in its JSON eg:
{ "data": [1,2,3] }
How can I do that with webRequest and WWWForm or IMultipartFormSection.
Solution 1:[1]
You can review this
Just create a class with the names of the variables you want to send and then call this class and send it with the UnityWebRequest If you don't know how to create a class and put variables in it here is a simple example
public class Thename()
{
public string _1;
public string _2;
public string _3;
}
public Thename _Thename;
IEnumerator RequestPOST()
{
_Thename._1 = "Any";
_Thename._2= "asdsad";
_Thename._3= "Bla Bla";
UnityWebRequest www =
UnityWebRequest.Post("http://localhost:3000/api/rawCoords",
Thename);
www.SetRequestHeader("Accept", "application/json");
yield return www.Send();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Lelouch kun |
