Skip to content

The Swagger API documentation has a slight issue when making a POST/PUT request to the API with a JWT #23

@LePhenix47

Description

@LePhenix47

So the documentation has a slight issue when making POST or PUT requests

When making a POST or PUT request, we must input a string with the keyword “Bearer” and then the JSON Web Token, like this:

"Bearer [JWT]"

Though there's a problem, for some unknown reason, when making the POST/PUT request,

Curl adds another double-quote at the end of the Authorization string value, making the token invalid:

image

So the developer has to remove the last double quote at the end of the JWT, so we end having to input the token like this:

"Bearer [JWT]

for the POST request to work properly

How to reproduce this error yourself

  1. Start the Back-End server and go to the Swagger API doc. with this address: http://localhost:3001/api-docs/#/

  2. Go to the User Module → POST - /user/login/ → add the “[email protected]” to the email and “password123” for the password:
    image

  3. Click “execute” and copy the JWT without the double quotes:
    image

  4. Go to POST - /user/profile/ → Input your JWT like this:

"Bearer [JWT]"

Example:
image

(NB: I changed the width of the input in CSS to make the entire JWT visible)

  1. Click the “Execute” button, and you'll see an error message that the token is invalid:
    image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions