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
Sending null values in post request #1184
Comments
Can you post your code and tell us which k6 version you are using, since this seems like a bug, but I can't reproduce it. This code: import http from "k6/http";
export default function () {
let resp = http.post("https://httpbin.org/post", null);
console.log(resp.body);
} produces
which seems normal |
Hi @na-- thanks for your quick response. Im sorry my last post wasnt clear at all
my response i get within the node api is
|
This is duplicate of #878, so I am closing this. For a quick fix you can use import http from "k6/http";
export default function () {
let payload = {
username: "myusername",
password: "mypassword",
company_id: null ,
vendor_id : null ,
ldap_id : null ,
};
let params = {
"Content-Type": "application/json"
};
let resp = http.post("https://httpbin.org/post", JSON.stringify(payload), params);
console.log(resp.body);
} will get you: {
"args": {},
"data": "{\"username\":\"myusername\",\"password\":\"mypassword\",\"company_id\":null,\"vendor_id\":null,\"ldap_id\":null}",
"files": {},
"form": {},
"headers": {
"Content-Length": "99",
"Host": "httpbin.org",
"User-Agent": "k6/0.26.0-dev (https://k6.io/)"
},
"json": {
"company_id": null,
"ldap_id": null,
"password": "mypassword",
"username": "myusername",
"vendor_id": null
},
"origin": "46.233.49.37, 46.233.49.37",
"url": "https://httpbin.org/post"
} I have also opened new issue to fix the problem when urlencoding: #1185 |
@mstoykov thanks for your response i did have a check on existing issues and couldn't find a similar one, obviously i didn't look hard enough. |
Don't worry @Lex-talionis, the issue wasn't easy to find since it stated the same problem in a different way... We just knew it because we've hit it before, and even then, your issue told us something that we didn't know before about the way |
Use blank string instead of null in your json format like this:
|
Hi, when trying to sending a null value to a post endpoint, k6 converts null into
'<nil>'
. is there a way to fix this in my end?The text was updated successfully, but these errors were encountered: