0

If PUT and DELETE operations can be performed on a profile resource by passing either profileId or profileName (both are unique), what is the right way to form URLs?

I want to support both update and delete operations on a profile resource when sending the profileId and support both update and delete operations on a profile resource when sending the profileName.

When sending the profileId, the URL for performing PUT operations would look like:

/api/profiles/{profileId}

How would the URL look like when sending the profileName? Should the profileName be sent as a query parameter?

/api/profiles?profileName=uniqueProfileName

Or is there any better way to handle this scenario?

cassiomolin
  • 124,154
  • 35
  • 280
  • 359
VGH
  • 305
  • 6
  • 20
  • this will help you here you will find how to send an array in url, with this array you can treat the ids that you want to delete. http://stackoverflow.com/questions/6243051/how-to-pass-an-array-within-a-query-string – David alejandro Idarraga Marti May 17 '16 at 07:12
  • We want to support both : That's Update/Delete a profile by profileId and Update/Delete a profile by profileName – VGH May 17 '16 at 07:15

1 Answers1

1

You could use the profileId as a main identifier for your profile resources:

/api/profiles/{profileId}

And you could support the {profileName} as a secondary identifier by using a query parameter:

/api/profiles?name={profileName}

Or a matrix parameter:

/api/profiles;name={profileName}
cassiomolin
  • 124,154
  • 35
  • 280
  • 359
  • I've designed the `ProfileResource` to support both main identifier and secondary identifier (profileId and profileName). Getting an error. Question has been updated. Can you please help me on this ? – VGH May 18 '16 at 11:08
  • @VGHegde It looks out of the scope of the original question. Why don't you ask a new question. I'll be happy to help you there. *Tip:* you could use the query string in the method that returns all profiles and avoid ambiguity. – cassiomolin May 18 '16 at 11:13
  • 1
    New question : [link](http://stackoverflow.com/questions/37298844/designing-rest-resource-to-support-multiple-methods-which-produces-and-consumes) – VGH May 18 '16 at 11:56