i am trying to Post request Using Unity web request i created a pure php API For Testing After that Web developer Created API For Me To Work on it but the Link is little different syntax of the pure php i was work on my Pure PHP Link is : http://localhost/sqlconnect/register.php The New API Link is : http://localhost/fighting/public/player/register
so the first one is .php is working the second one doesn't have .php extension and it is not working so , What is the Problem and How To Solve it BTW the both of them Tested and successful work on the Web browser
This one works Ver Well
IEnumerator Register_New ()
{
WWWForm form = new WWWForm();
// string form= "?player_name="+name_Field.text+"&password="+Password_Field.text+"&api_key=omar";
form.AddField("player_name", name_Field.text);
form.AddField("password", Password_Field.text);
form.AddField("api_key", "omar");
UnityWebRequest www = UnityWebRequest.Post ("http://localhost/sqlconnect/register.php", form);
www.SendWebRequest();
print(www.url);
yield return www;}
This one Doesn't Work
IEnumerator Register_New ()
{
WWWForm form = new WWWForm();
// string form= "?player_name="+name_Field.text+"&password="+Password_Field.text+"&api_key=omar";
form.AddField("player_name", name_Field.text);
form.AddField("password", Password_Field.text);
form.AddField("api_key", "omar");
UnityWebRequest www = UnityWebRequest.Post ("http://localhost/fighting/public/player/register", form);
www.SendWebRequest();
print(www.url);
yield return www;}
You say they work in the web browser. This leads me to believe that the endpoints are accepting GET requests rather than POST, since GET is what you do when you type in a URL into the address bar. And by the way, your commented code also looks like a GET with a querystring. Are you sure you should be posting to the endpoints? Try it with UnityWebRequest.Get just to be sure.