Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4164

Web API Restful : Get resource by foreign key [closed]

$
0
0

My question is about the "correct way" to name the route in a .NET core web API of the following case:

enter image description here

  • a bank account is always related to a Enterprise.
  • a Enterprise can have multiple bank accounts
  • a contract has always one bank account

so I have resources like that:

/api/enterprise/1 // get enterprise 1/api/contract/1 // get contract 1/api/bank-account/1 //get bankaccount  1

My question is, what is the best way to get enterprise bank accounts?

first idea :

use query string as a "search-terms"

api/bank-account?EnterpriseId=1

second idea

use child resource

api/enterprise/1/bank-account

but if I do that I have multiple "bank-account" in different level, I don't know if is it a good way?

api/enterprise/1/bank-account //bank-account level2api/bank-account //bank-account level1

I think the second idea is a good way but I'm not sure if a can manipulate same "model" on different level of the API.


Viewing all articles
Browse latest Browse all 4164

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>