I've got the following request from my employer and I was wondering if you could give me a suggestion.
For simplicity here is an example of what I have for the following get student controller
I've created a GET route with the following parameters api/students/{LcID}/{AffiliateId}/{StartDate?}/{EndDate?}/{Email?}
The StartDate, EndDate, and Email are optional parameters. Everything works fine with this setup but my employer wants to know if the client can just send the LcId, AffiliateId, and Email. Can that be done?
I've tried using Postman to set the name and value parameters LcID=1/AffiliateId=123/[email protected] but that didn't work.
Should I change my parameters into an object that needs to be passed in? I don't really want the user to have to fill in the other fields with dummy values in-between the parameters that do get filled in. I hope this makes sense.
You can add another Route
to your Action
, like the following:
[HttpGet("LcID={LcID}/AffiliateId={AffiliateId}/{StartDate?}/{EndDate?}/{Email?}")]
[HttpGet("LcID={LcID}/AffiliateId={AffiliateId}/Email={Email}")]
If there are other requirements, you can continue to add them.