1

I have the list of students with id, firstName, lastName and email, and I have put http method that has two arguments, id and student which finds the student with given id and replace that student whit new one (second parameter).

I have to send that put http request as JSON, but I don't know how to write that request properly. This is what I tried:

{
    "id": 8,
    "firstName": "aaaa",
    "lastName": "aaaa",
    "email": "aaaa"
},
{
"id: 2"
}

So the student with id = 2 should be replaced with the student above. Basically I have trouble making this request with two parameters.

2 Answers 2

2

include the id of the student you want to replace on the url. Something like:

server:port/yourapp/student/2

Use the body only for the data related to the student you want to write in the db.

However, changing an id doesn't seem very restful.

Sign up to request clarification or add additional context in comments.

Comments

1

You can create a custom object model that will hold a student and an additional parameter (id of another student):

{
    "student":
    {
        "id": 8,
        "firstName": "aaaa",
        "lastName": "aaaa",
        "email": "aaaa"
    },
    "studentId": 2
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.