这是我的API请求
public IEnumerator Login(string bodyJsonString)
{
Debug.Log(bodyJsonString);
UnityWebRequest req = UnityWebRequest.Post("localhost:3000/login",bodyJsonString);
req.SetRequestHeader("content-type","application/json");
yield return req.SendWebRequest();
if (req.isnetworkError || req.isHttpError)
{
Debug.Log(req.error);
}
else
{
Debug.Log("Form upload complete!");
}
}
它返回错误状态代码500,并在服务器上返回错误JSON位置0“,”严重性
上的意外令牌%这是我的协程电话
public void submitLogin()
{
_username = userInputField.getcomponent<InputField>().text;
_password = passwordInputField.getcomponent<InputField>().text;
Debug.Log("username" + _username);
Debug.Log("password" + _password);
string body = "{'username':'" + _username + "','password','" + _password + "'}";
//API Call
authChexi = new Auth();
StartCoroutine(authChexi.Login(body));
}
让我知道您是否对如何处理我的表单有任何想法。谢谢