Newbie-Is it Mandatory when I POST some details, the response body should contain id in return?for eg:A contact

My question:
Is it Mandatory when I POST some details, the response body should contain id in return?for eg:A contact

Details (like screenshots):

I would like to create a contact, get the contact details using an id, update a contact then delete the same contact. How should I automate it? I am Stuck up inbetween.

How I found the problem:
When I post a contact ,whatever I filled as firstname ,lasname,address is displayed in response body. But I am not able to get the generated id corresponding to the contact. After which each time I have to goto GET the list of contacts to see the newly created contact.Is there any way I can get the Contact id from the response body,So that i can use it in my next GET method

I’ve already tried:to find the path of id that displays in GET all contacts method using the JSON path locater. but it dint help. Is that the correct way? Please help

1 Like

It is not mandatory for the response to contain an id after a POST request, but it is often the case.
Some APIs will even return the entire data object in the response, including the internal id.

Thanks for your reply. I have to get the ID after I post a request and use the same for executing the next testcase to update . In that case if the response of POST does not return its id how can I proceed with next testcase?

In this case, you need to find another endpoint that has this info.

Maybe one that offers a list of all items, and you need to search through that to get the id.

1 Like

Thank you I am going to try that