REST models with single service APIs?

  • 1
  • Question
  • Updated 2 years ago
  • Answered
Is it possible to use declarative REST models without a query method? For example, currently I'm unable to use a service-based API (POST data to one endpoint, receive a response), as it isn't a traditional CRUD API, and doesn't have GET response.

The current REST models seem to require CRUD operations to function. Is there a way around this, or am I restricted to a custom JS solution for now?
Photo of mB Remi Gelinas

mB Remi Gelinas

  • 374 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of telennar


  • 90 Points 75 badge 2x thumb
I was just doing this. I defined a create method and fields for each item I wanted to send in the request or retrieve from the response. In an action I then added a row to the model and then saved the model.
Photo of Zach McElrath

Zach McElrath, Employee

  • 55,228 Points 50k badge 2x thumb
You can do this by adding Model Fields for both request and response information, to the same Model. For example, let's say your Model has an Insert method that does a POST, and you need to send fields "Foo" and "Bar". You would define two Model Fields, "Foo", and "Bar". Now, if the response from the POST is expected to return fields "Alpha" and "Beta", you should add these as Model Fields as well. Then, in your Insert method config, make sure that "Created record will be returned in response body" is selected. After the POST response comes back, if it contains "Alpha", "Beta", "Foo", and / or "Bar" properties, these will all be populated into the corresponding fields in the Model rows.