IEnumerator Put(string url, bool value, ActionListener listener) { string body = "{\"power\":\"" + (value?"ON":"OFF") + "\"}"; var www = new UnityWebRequest(url, "PUT"); byte[] bodyRaw = Encoding.UTF8.GetBytes(body); www.uploadHandler = (UploadHandler) new UploadHandlerRaw(bodyRaw); www.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); www.SetRequestHeader("Cookie", string.Format("device={0}", token)); www.SetRequestHeader("Content-Type", "application/json"); yield return(www.Send()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); listener.Response(Result.Error); } else { listener.Response(Result.Ok); } }