Email Address in Web API GET request

前端 未结 2 1691
忘了有多久
忘了有多久 2021-01-16 06:46

I\'m working on a REST APIs implemented in ASP.NET Web API. One scenario we\'d like to support is to do a GET request of some user information by email address.

2条回答
  •  生来不讨喜
    2021-01-16 06:58

    Can you try the following and see if it works for you?

    GET: /api/v1/users/email?id=your_email%40your_domain.com
    

    This assumes your controller's Get function is something like this: Get(string id), i.e. it takes a parameter called id of type string. If you want it to take, for example, a parameter called "emailAddress", then you would do:

    GET: /api/v1/users/email?emailAddress=your_email%40your_domain.com
    

    Note the @ sign is encoded as %40. This also assumes your controller is called EmailController.

提交回复
热议问题