PUT error: All object fields are null

Asked

Viewed 44 times

1

I have a user with id 3, a car with id 6 and I do a POST on the rental passing these 2 id’s, until then ok, the GET returns this

{
        "id": 5,
        "usuarioCliente": {
            "id": 3,
            "nome": "Arthur",
            "cpf": "281.590.328-89",
            "cnh": "35214349616",
            "telefone": "(61) 99805-2147",
            "email": "[email protected]",
            "senha": "1234",
            "perfil": "alugador",
            "endereco": {
                "id": 3,
                "logradouro": "Quadra SHPS Quadra 502",
                "bairro": "Setor Habitacional Pôr do Sol (Ceilândia)",
                "numero": 927,
                "complemento": " ",
                "cidade": "Brasília",
                "estado": "DF"
            }
        },
        "carro": {
            "id": 6,
            "usuarioRegistrador": {
                "id": 3,
                "nome": "Arthur",
                "cpf": "281.590.328-89",
                "cnh": "35214349616",
                "telefone": "(61) 99805-2147",
                "email": "[email protected]",
                "senha": "1234",
                "perfil": "alugador",
                "endereco": {
                    "id": 3,
                    "logradouro": "Quadra SHPS Quadra 502",
                    "bairro": "Setor Habitacional Pôr do Sol (Ceilândia)",
                    "numero": 927,
                    "complemento": " ",
                    "cidade": "Brasília",
                    "estado": "DF"
                }
            },
            "kmsRodados": 2.0,
            "documentoCarro": "3",
            "tipoCombustivel": "4",
            "marca": "Marca",
            "modelo": "Modelo",
            "placa": "bbb-1555",
            "valorCarro": 363636.0,
            "estaAlugado": true
        },
        "retirada": "2009-08-08",
        "entrega": "2019-08-05",
        "valor": 500.0
    }

When I make a PUT in rent, the idea is to change only the value and dates of withdrawal and delivery, the objects "car" and "user" must remain intact.

{
    "id": 5,
    "usuarioClienteId": 3,
    "carroId": 6,
    "retirada": "2000-01-01",
    "entrega": "2000-01-01",
    "valor": 33
}

When I run PUT, GET brings the right changes but all fields of the car object and user are null !!

{
    "id": 5,
    "usuarioCliente": {
        "id": 3,
        "nome": null,
        "cpf": null,
        "cnh": null,
        "telefone": null,
        "email": null,
        "senha": null,
        "perfil": null,
        "endereco": null
    },
    "carro": {
        "id": 6,
        "usuarioRegistrador": null,
        "kmsRodados": 0.0,
        "documentoCarro": null,
        "tipoCombustivel": null,
        "marca": null,
        "modelo": null,
        "placa": null,
        "valorCarro": 0.0,
        "estaAlugado": false
    },
    "retirada": "2000-01-01",
    "entrega": "2000-01-01",
    "valor": 33.0
}

What can I do to make it right?

  • the Rest request method does not influence how something will be saved, it is necessary to see how you are updating the object

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.