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.

asked Jul 20, 2021 at 11:11

1 Answer 1

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.

answered Jul 28, 2021 at 14:51

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.