I'm trying to go through post
the data of a small form made in unity.
When I create a user employment;
public void NewAccount ()
{
List formData = new List();
formData.Add (new MultipartFormDataSection ("name", _newNameIntroduced.text));
formData.Add (new MultipartFormDataSection ("password", _newContrasenaIntroducida.text));
UnityWebRequest www = UnityWebRequest.Post (_newUserURL, formData);
StartCoroutine (WaitForRequest (www));
}
Method which works perfectly.
The problem comes when sending the data to authenticate the user;
public void VerifyAccount ()
{
List formData = new List();
formData.Add (new MultipartFormDataSection ("name", _ nameIntroduced.text));
formData.Add (new MultipartFormDataSection ("password", _ contrasenaIntroducida.text));
UnityWebRequest www = UnityWebRequest.Post (_LoadUserURL, formData);
Debug.Log ("1");
StartCoroutine (WaitForRequest (www)); Debug.Log ("1.5");
}
Method WaitForRequest
;
private IEnumerator WaitForRequest (UnityWebRequest postUser)
{
Debug.Log ("2");
yield return postUser.SendWebRequest ();
Debug.Log (postUser.downloadHandler.text);
if (Convert.ToInt32 (postUser.downloadHandler.text)! = 200)
{
#if UNITY_ANDROID &&! UNITY_EDITOR
dialog.showDialog ("Error");
#endif
Debug.Log ("Error");
}
else
{
#if UNITY_ANDROID &&! UNITY_EDITOR
dialog.showDialog ("Success");
#endif
Debug.Log ("Success");
}
}
The debug remains at 1.5 (message I print) and then spits the following error;
FormatException: Input string was not in the correct format
System.Int32.Parse (System.String s) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Int32.cs:629)
System.Convert.ToInt32 (System.String value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Convert.cs:1270)
If to this method I enter only integer values in the input
the method is executed without exception, which I do not understand since NewAccount ()
It admits numbers and letters.