Yii Framework Forum: REST API get user by id and by email id - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

REST API get user by id and by email id

#1 User is offline   kapilsharma 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 07-April 17

Posted 08 April 2017 - 06:40 AM

I am creating APIs for fetching user by ID and by EmailId, But fetch by email id is not working.

Here is my code

urlManager

  'users/<userEmail:[A-Za-z0-9 -_.]+>' => 'users/user-by-email',
        'users/<id>' => 'users/',


I have implemented API by using Swagger.
Here is my swagger code

/**
     * @SWG\Get(path="/users/{userId}",
     *     tags={"users"},
     *     summary="Get user details by userId.",
     *     description="Get user details by userId.",
     *     produces={"application/json"},
     *     @SWG\Parameter(
     *        in = "header",
     *        name = "Authorization",
     *        description = "API secret key",
     *        required = true,
     *        type = "string",
     * 		  default = "Bearer 4p9mj82PTl1BWSya7bfpU_Nm8u07hkcB"
     *     ),
     *     @SWG\Parameter(
     *        in = "path",
     *        name = "UserId",
     *        description = "User userId",
     *        required = true,
     *        type = "integer",
     * 		  default = "1"
     *     ),
     *
     *     @SWG\Response(
     *         response = 200,
     *         description = " success"
     *     )
     * )
     *
     */
    /**
     * @SWG\Get(path="/users/{userEmail}",
     *     tags={"users"},
     *     summary="Get user details by email.",
     *     description="Get user details by email.",
     *     produces={"application/json"},
     *     @SWG\Parameter(
     *        in = "header",
     *        name = "Authorization",
     *        description = "API secret key",
     *        required = true,
     *        type = "string",
     * 		  default = "Bearer 4p9mj82PTl1BWSya7bfpU_Nm8u07hkcB"
     *     ),
     *     @SWG\Parameter(
     *        in = "path",
     *        name = "userEmail",
     *        description = "User email",
     *        required = true,
     *        type = "string",
     * 		  default = "myemil@email.com"
     *     ),
     *
     *     @SWG\Response(
     *         response = 200,
     *         description = " success"
     *     )
     * )
     *
     */

0

#2 User is offline   dannythebestguy 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 27-June 12

Posted 06 June 2017 - 09:28 PM

Even I have this issue. Any help ?
0

#3 User is offline   Nikola Tesic 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 10
  • Joined: 04-June 17

Posted 07 June 2017 - 01:45 AM

Maybe need to urldecode() userEmail param from url?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users