0

My application has a grid with a list of Car objects from a third party system

[{id: 1, make: "Ford", model: "Focus", ...},...]

The user can select a Car and use its data (after some transformation) to create a Car specific to my application. The app does this by filling in a form on another HTML page with the transformed 3rd party Car data and allowing the user to modify data as needed.

When the app makes the request to retrieve the transformed 3rd party car data, should that request be a HTTP GET (even though it transformed the data (in a repeatable way))? What should the URL be using REST standard formats? I don't think it should be /third-party/car/{id} since that is for returning the third party car as-is.

Update

Here's an overview of the architecture: enter image description here

The diagram shows the URLs supported. The flow is:

  1. Client requests HTTP GET /third-party/cars/{id}/transform, HTTP GET /cars/third-party-cars/{id} or some other URL. This is the URL in question.
  2. My application receives the request and does the following:
    • Gets the 3rd party version of the car from the 3rd party DB
    • Transforms the 3rd party car in the CarService or ThirdPartyCarService to my application's version of a car (i.e. Car)
    • Populates and returns an HTTP form with Car data
  3. The user then modifies the Car data as needed
  4. The client either requests the Car data is saved via HTTP POST /cars or cancels.
  • 1
    You're overthinking this. If the system is expected to provide a response to the form directly, just use a POST. If you need to retrieve the car later, use a GET. There's no such thing as a REST standard format for an URL. If you want some guidelines anyway, look here: restfulapi.net/resource-naming – Robert Harvey Jan 17 at 23:38
  • Thanks Robert. Yes, the system will provide data to populate the form. The user can then either cancel out of the form or submit the form. Submitting the form will save the car data and I know that request should be a POST request. But you're saying that the request to get the transformed data for pre-populating the form should also be a POST? – James Jan 17 at 23:52
  • I guess the retrieval of the transformed data is always going to be a GET. – Robert Harvey Jan 17 at 23:57
  • Suggestions for the URI? After reading restfulapi.net/resource-naming, I think this may be suitable as a controller archetype. For example, http://localhost/third-party/cars/{id}/transform. But it's a bit odd because the return value (mapped resource) is actually an unsaved car. Saved cars are returned by http://localhost/cars/{id}. – James Jan 18 at 18:48
  • Why don't you just return the transformed car? – Robert Harvey Jan 18 at 18:51

Your Answer

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

Browse other questions tagged or ask your own question.