The UriTemplate of my Service looks like this:
[WebGet(UriTemplate = "LoginUser/authorizationCode/{authorizationCode}/userId/{userId}/intend/{intend}/email/{email}")]
The function looks like this:
public User LoginUser(string authorizationCode, string userId, string intend, string email)
My usual call looks like this:
http://localhost:60522/MyService.svc/json/LoginUser/authorizationCode/111222333/userId/0006435cec5aa5640639b5d08314bb989a43519/intend/yyy/email/[email protected]
My next task is to make the intend and email parameter optional.
So my call has to work in all of these variants:
http://localhost:60522/MyService.svc/json/LoginUser/authorizationCode/111222333/userId/0006435cec5aa5640639b5d08314bb989a43519/intend/yyy/email/[email protected]
http://localhost:60522/MyService.svc/json/LoginUser/authorizationCode/111222333/userId/0006435cec5aa5640639b5d08314bb989a43519/intend/yyy
http://localhost:60522/MyService.svc/json/LoginUser/authorizationCode/111222333/userId/0006435cec5aa5640639b5d08314bb989a43519/email/[email protected]
http://localhost:60522/MyService.svc/json/LoginUser/authorizationCode/111222333/userId/0006435cec5aa5640639b5d08314bb989a43519
How do I edit my template and function to make it work?
You can set the default values of intend and email to null, as shown below:
We can access this service via the URI below:
http://localhost:8000/LoginUser/authorizationCode/Test/userId/Test/intend/
http://localhost:8000/LoginUser/authorizationCode/Test/userId/Test/intend/int/
http://localhost:8000/LoginUser/authorizationCode/Test/userId/Test/intend/int/ema/
In this scenario, if you want to set email, you must set the intend.
So I think the best way is to write an interface for them separately like below:
Different interfaces will be requested for different URIS;