Sending Values via UnityWebRequest.post

Good evening everyone,

Not sure if I’m in the right forum but I could use some help.
For a Demo I need to change a value on the server with a post method.

The finished url should look like “http://…/urlLightState?value=true” for example. (so the value defines if the light is on or off in this case it should turn on the light)

This is what my code looks like:


request = GameObject.FindGameObjectWithTag(“Settings”).GetComponent().UrlLightState;

form.AddField(“state”, “” + _lichtState);

UnityWebRequest www = UnityWebRequest.Post(request, form);

yield return www.Send();

while ()
{
Debug.LogError(“.”);
yield return null;
}

if (www.isNetworkError)
{
Debug.Log(www.error);:wink:
}
else
{
Debug.Log(www.downloadHandler.text);:wink:
string temp = www.downloadHandler.text;

Debug.Log(temp);
}


As return from both Debugs i get:

--------------------------------------------------------------------------------------------------------------------- Not sure if I'm using the right method / understood the method right but I whould apreciate any ideas! As long as the right link will be sended I'm happy Thanks for your help.

Does the POST request redirect to that URL, which has that value=true query?
If so, then you should read the www.url property after request is complete.