1

Here is what I have so far:

[Route("EndTest/{examId:int}/{userTestId:int}/{retrieve:boolean}")]
public async Task<IHttpActionResult> EndTest(int examId, int userTestId, bool retrieve)

Can someone validate if this is the correct way to do this, if it is even possible and if so then how could I pass the boolean with a Http call?

1 Answer 1

1

According to this Route Constraints you need to change boolean to bool.

//eg: GET /EndTest/1234/56789/true
[HttpGet]
[Route("EndTest/{examId:int}/{userTestId:int}/{retrieve:bool}")]
public async Task<IHttpActionResult> EndTest(int examId, int userTestId, bool retrieve) {...}

It is also good practice to indicate what HTTPMethod is allowed when adding route attributes that do not conform to the default convention used by the framework. I added HttpGetAttribute in my example.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.