0

Here is the full question :

As a Portfolio API, I should be able to retrieve details for a given Account and Account type from Balance API, so that i can pass over the same to the UI for the end users to view the same.

Scenario 1 - Verify the response when Portfolio API invokes the POST /v1/accDetails endpoint for a given account details (Checking)

Given client has a valid auth token for the api

And Portfolio API has the following

Account Number 1234567890 (10 characters).
Account Type 'CHQ' (3 characters)

When Portfolio API sends a POST request to Balance API

Then Portfolio API will receive the response code as <00>

And response body will have the following (not limited to below fields)

Account Type, Account Number, Account ID, Account Name, Account Balance, Product TypABA Number, Interest Rate, Interest Earned to DateStatus.

Now my question is we can do this using GET Method but can we do this using POST method or not? When we use post that mean we are going to add something but I do not want to add any account. I just want to get account details.

Bonny
  • 511
  • 5
  • 12

1 Answers1

1
  • Since you have only a few parameters to send via GET, the best approach is to use [GET].
  • We can use the [POST] if we really need it to do so.
  • But if you can use [GET] for that, then the best approach is to use [GET].
  • Also can refer: REST API using POST instead of GET.
  • But If I use a post, a post is used to create some resource on the server. How can I get response out of it? For example I want to fetch my account details by passing Account number. Can I do that using POST? If yes. Could you walk me through it? – Bonny Jun 16 '21 at 14:23
  • We can implement the post request to retrieve the data, not only for creation. In your case create post service in your serverside for post request body like {"accountNumber": "A334534-B3"} and you can implement the response as return the account details as post 200 ok response code and staus instead of 201 created. By 200 Ok users can identify request became a success. – Rajith Kariyawsam Jun 17 '21 at 03:49
  • Just to make sure, Am I supposed to send this request in body or queryparam? – Bonny Jun 17 '21 at 14:10
  • As I mentioned in the answer better if you can implement this service as GET method which is recommended, But no harm if you need you can use POST. If you going to use GET method then you have to use query param, But If you are planning to use POST then data should be sent in the request body. – Rajith Kariyawsam Jun 18 '21 at 06:17
  • First, you decide whether you going to use GET or POST. (Better if you can use GET in your scenario due to few query parameters are there). But If you already implemented the backed API service then the request has to send as per that. – Rajith Kariyawsam Jun 18 '21 at 06:24