0

I have a resource called Client and it has the following attributes id, name, redirect URLs(ArrayList).

class Client{
   int id;
   String name;
   List<String> redirectUrls;
}

I have all CRUD http request mappings over resource Client. In the get method I fetch the resource from database and give to client, however my firewall blocks the put requerst when user submits the put request to update the resource since it carries collections of urls(redirectUrls) within the request body.

So, I have this requrement to design an API only to update the collection of given Client. Let's say for a given Client I have 10 redirectUrls(loaded in the Client UI) and as soon as the client adds a new redirectUrl, my client calls this new API with the redirectUrl and it gets added to collection in the backend. At any given point of time when client adds new redirectUrl the API gets called.

The question here is how should I design my API so that only this particular attribute(redirectUrl list) gets updated with the coming redirectUrl. One option is PATCH API but this one should ideally replace the whole attribute value with new vlaue, which is not what supposed to happen in my case.

Any help is much appreciated. Thanks.

0

You could model the redirect URLs as a sub resource, e.g.

/clients
/clients/4711
/clients/4711/redirect-urls

To add a new redirect URL to the collection you would simply use POST /clients/4711/redirect-urls.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.