I want to understand what should be the right request/response structure and API design to solve below problem. I have 2 entities let say Abc and Xyz. And Xyz has a foreign key of Abc. So, to create a record for Xyz, there has to be mapped Abc record.
Now for request structure point of view, I need to create one POST request for Abc that is like
POST /Abc
This is pretty much straightforward. But the problem is with Xyz. The requirement is whenever a user came for to create Xyz, he may also request to update the attached Abc record, too. For example, I have created a record for Abc with id 5. Now, whenever I want to create a corresponding Xyz record, I will request to update the Abc record with id 5 and create a new Xyz record for this foreign key. So, PATCH /Abc and POST /Xyz But the client requests only once and share whole data on single URI.
So, what is the right way to handle multiple HTTP methods on single URI? Should I create POST request or PATCH?
I couldn't create 2 requests because the client wants this process as transactional.