Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

401 Unauthorized Response on Post Request using Bearer Token Authorization type #1451

Closed
LearningNeverEnds opened this issue May 15, 2020 · 3 comments

Comments

@LearningNeverEnds
Copy link

Environment

Expected Behavior

Post request should create a data with provided extracted Bearer token and payload data

Actual Behavior

401 Unauthorized Response

Steps to Reproduce the Problem

  1. `k6Perf.js:

K6_1

  1. In first function I am extracting the Bearer token and storing it in var token and passing the var onto second function that will create a data.

  2. K6 response Log:

K6_2

K6_3

Please let me know what am I doing wrong. I was able to send the same post request using JMeter, Postman and Rest Assured....I been trying to get this done and add this script as my Load Test Stage into my GitLab CI Pipelines. But I am struck :(

Thank you in advance!

@gomespauloho
Copy link

The parameters used in the post method are in the wrong order, the correct order would be:

image

  let res = http.post(`${API_SERVER}/api/donors`, {
    ...body
  }, {
    headers
  });

@LearningNeverEnds
Copy link
Author

It is working now :) Thank you so much!

@na-- na-- added question and removed bug labels May 16, 2020
@na-- na-- closed this as completed May 16, 2020
@MichelCorreaDaLuz
Copy link

@gomespauloho 4 years has passed, and today you saved me as well.
Thanks a lot for making me read the documentation properly hahaha

God bless u

@ankur22 ankur22 removed their assignment Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants