- Home /
UnityWebRequest - login page returns a "not found"
I'm trying to send a POST form to a login validation page using UnityWebRequest. I tried using MultipartFormSection, but the object redirects back to the validation page. I tried using WWWForm instead, and the URL says that it has correctly redirected to the member page, but the content says "page not found". I already made a GET request on the login page and set the cookies it set as the request header for the POST.
Here is the code:
var formData = new List<IMultipartFormSection>();
formData.Add(new MultipartFormDataSection("txtnamapengguna", username));
formData.Add(new MultipartFormDataSection("txtkatalaluan", password));
formData.Add(new MultipartFormDataSection("btgcari", "Log+Masuk"));
formData.Add(new MultipartFormDataSection("txtaction", "login"));
WWWForm form = new WWWForm();
form.AddField("txtnamapengguna", username);
form.AddField("txtkatalaluan", password);
form.AddField("btgcari", "Log Masuk");
form.AddField("txtaction", "login");
www = UnityWebRequest.Post("https://apdm.moe.gov.my/index.php?modul=action&muka=login", form);
www.downloadHandler = new DownloadHandlerBuffer();
www.SetRequestHeader("Cookie", headers["Set-Cookie"]);
yield return www.Send();
if (!string.IsNullOrEmpty(www.error))
{
MainController.UpdateOutput("ERROR: " + www.error);
DestroyImmediate(canvas.gameObject, true);
yield break;
}
else
{
string loginOutput = www.url + "\n" + www.downloadHandler.text;
Debug.Log(loginOutput);
MainController.UpdateOutput(loginOutput);
DestroyImmediate(canvas.gameObject, true);
}
Note that I'm trying to log into a third-party page in order to send data there, but since I don't manage their servers, I can't make catcher pages to make this easier.
Your answer
Follow this Question
Related Questions
Command method dont change variables on server 0 Answers
Understanding Unet attributes 2 Answers
Transport Layer WrongHost 1 Answer
Distribute terrain in zones 3 Answers
WWW with https resulting in SSL: couldn't create a context 0 Answers