Created
October 3, 2022 10:41
-
-
Save junaid109/7489a85d1ffb3177ff7e984c1bd2eed5 to your computer and use it in GitHub Desktop.
Post method in unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private IEnumerator PostRegistrationDetails(string jsonData) | |
{ | |
var raw = Encoding.UTF8.GetBytes(jsonData); | |
using UnityWebRequest webRequest = UnityWebRequest.Post(uriPostResults, "POST"); | |
webRequest.SetRequestHeader("Content-Type", "application/json"); | |
webRequest.uploadHandler = new UploadHandlerRaw(raw); | |
webRequest.uploadHandler.contentType = "application/json"; | |
webRequest.downloadHandler = new DownloadHandlerBuffer(); | |
webRequest.SendWebRequest(); | |
if (webRequest.isNetworkError || webRequest.isHttpError) | |
{ | |
Debug.Log("Error: " + webRequest.error); | |
} | |
else | |
{ | |
Debug.Log("Success"); | |
} | |
yield return new WaitForSeconds(1f); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment