Problem with UnityWeb request Network error

Hi i am trying to send data to my rest api with a simple unity web request post ,
but it dosent update my database and in the logs it shows me its a network error
here is my code :
user.id_token and the other fields all have data when i send it
If anyone can help it would appreciated
Unity.

public IEnumerator Registrar(User user)
    {
        string url = " http://127.0.0.1:8000/api/usuarios/store/";

        Debug.Log("Creo la form en registrar ");

        WWWForm form = new WWWForm();
        form.AddField("ID_TOKEN", user.id_token);
        form.AddField("PROCEDENCIA", user.procedencia);
        form.AddField("IDIOMA", idioma(user.idioma));
        form.AddField("APP_ID", 1);
        Debug.Log(form);

        using (UnityWebRequest request = UnityWebRequest.Post(url, form))
        {
            yield return request.SendWebRequest();
            if (request.isNetworkError)
                Debug.Log("eRROR de network en registrar ");
            if (request.isHttpError)
            {
                Debug.Log("eRROR de HTTP en registrar ");
            }
            else
                Debug.Log("usuario   registrado correctamente en registrar");
        }
    }

The route
Route::post('/usuarios/store','App\Http\Controllers\UsuarioController@store');The controller

public function store(Request $request)
    {
        $usuario = new Usuario();
        $usuario-> ID_TOKEN =  $request->ID_TOKEN;
        $usuario-> PROCEDENCIA =  $request->PROCEDENCIA;
        $usuario-> IDIOMA =  $request->IDIOMA;
        $usuario-> APP_ID = $request->APP_ID;
        $usuario->save();
    }

it works in post man

Your code send an HTML form, while your server expects JSON.

hi i remade the code to send a json

IEnumerator Post(User user)
    {
        Debug.Log("hago el post" );
        string url = " http://127.0.0.1:8000/api/usuarios/store";
        User usuario = new User();
        usuario.id_token =  user.id_token;
        usuario.procedencia = user.procedencia;
        usuario.idioma =  user.idioma;
        usuario.app_id = 1;
        string jsonusuario = JsonUtility.ToJson(usuario);
       
        var request = new UnityWebRequest(url, "POST");
        byte[] bodyRaw = Encoding.UTF8.GetBytes(jsonusuario);
        request.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw);
        request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
        request.SetRequestHeader("Content-Type", "application/json");
        yield return request.SendWebRequest();
        Debug.Log("Status Code: " + request.responseCode);
    }

And it still dosent work i got the code from here → Posting json through UnityWebRequest

in the log it says status code : 0

You have removed the error checking you had before. Looks like the request was not sent.

Yeah i put the error checking again and the problem is the same a network error

Of course it is. Print out the request.error and see what it says.

Hi it says that the request.isHttpError is true

  • if (request.isNetworkError)
  • Debug.Log("Error de network en registrar → " + request.isNetworkError);

I tried to use one of your previous solutions here → https://discussions.unity.com/t/729734

Doing the request…useHttpContinue = false;
and it didnt work either
Thank you for answering

What exact error does .error return?

This is the error


From :
print(“error de network en registrar → “+request.isNetworkError +” Error ->” +request.error);

Bump hi can you please help me ?

The error says unity failed to connect to your server.

Solved : The problem was that i had a space infront of http//
8188965--1067262--upload_2022-6-8_10-2-53.png
Thank you for the help i fell stupid xD