0

What is the correct way to setup GET and POST services in ApiGility?

Currently, if I am setting up a GET service, I will include the variable I require in my route:

/api/verify/merchant[/:merchant_code]

And if I wish to setup a POST service, my route becomes:

/api/verify/merchant

And I add a merchant_code 'field'

And if I want my route to accept both POST and GET, I then do this:

/api/verify/merchant[/:merchant_code]

and add a merchant_code field as well...

Is this the correct way to setup the routing for this?

Wilt
  • 41,477
  • 12
  • 152
  • 203
HappyCoder
  • 5,985
  • 6
  • 42
  • 73

1 Answers1

2

In general you POST your new entities on the collection endpoint so in your case /api/verify/merchant. The server will respond with a new resource with a self href for the newly created Merchant. This href will be formatted like /api/verify/merchant[/merchant_code] where merchant_code will be the identifier for the newly added Merchant resource.

Sending a POST request to /api/verify/merchant[/merchant_code] is not necessary/valid. You do GET, PATCH, DELETE or PUT requests on the endpoint of your Merchant resource depending on the action you want to perform (read, update, delete, replace).

Wilt
  • 41,477
  • 12
  • 152
  • 203