I want to call a login api in unity 3d with two json parameter username and password.
I followed many post available on stackoverflow. But my request parameters are not going on server. If I call this api from a my android app and postman and chorome, it is working fine there.
public IEnumerator CallLogin(string username,string password)
{
WWWForm form = new WWWForm();
form.AddField("username", username);
form.AddField("password", password);
UnityWebRequest www = UnityWebRequest.Post("/apis/login", form);
yield return www.Send();
if (www.error != null)
{
Debug.Log("Erro: " + www.error);
}
else
{
Debug.Log("All OK");
Debug.Log("Text: " + www.downloadHandler.text);
}
}
So my question is how to call a post api with json request in unity 3d.
Please help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…