Hi, I am running a script to upload a small text file to artifactory endpoint. I am passing my API key in the header.
Below is my script:
import http from 'k6/http';
import { check, sleep } from 'k6';
const textFile = open("/path/to/test1.txt")
export default function () {
const url = '<REST API end-point of artifactory>';
const params = {
headers: {
Authorization: "API_TOKEN",
'Content-Type': 'text/plain',
},
};
console.log(textFile)
const res = http.put(url, textFile, params);
check(res, {'status was 200' : (r) => r.status == 200});
console.log(res.status)
console.log(res.error_code)
}
When I am running this using k6 run I am getting below http response which is 401
INFO[0000] 401 source=console
INFO[0000] 1401 source=console
My API key is correct which I have validated using curl command.
Any idea why I am getting http 401 error. My plan is to eventually use the script in load testing artifactory REST endpoint.
Thanks