You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm testing a Service that is accepting the configuration JSON as a POST payload to it to perform a certain operation.
The payload of the POST method is not properly encoded for the nested object.
This is not really a bug because k6 doesn't serialize JS objects to JSON automatically, it serializes them to application/x-www-form-urlencoded or multipart/form-data. Only the map[...] bit is problematic and likely needs to be changed, though it's not clear it should be into JSON and not something else, e.g. what PHP does for nested objects: details[path]=/api/products&details[url]=.... There is no actual standard for encoding nested objects as HTTP body parameters, just different conventions from different programming languages or libraries 🤷♂️ This bug is tracked in #1185
#878 is the open issue about automatically marshaling JS objects to JSON request bodies in some cases. However, as explained in the issue comments and some of the linked discussions, it's unlikely we'll do it in the current version of the k6/http API because of too much ambiguity.
For now, you have to manually use JSON.stringify() for your JSON request bodies, like this:
I'll close this issue since it's mostly a duplicate of #878, please share any comments you have on this there. This is something we'll try to design better in the next version of the HTTP API, e.g. by having a dedicated REST Client that marshals everything to JSON by default or something like that.
Brief summary
Dear Team,
I'm testing a Service that is accepting the configuration JSON as a POST payload to it to perform a certain operation.
The payload of the POST method is not properly encoded for the nested object.
k6 version
v0.36.0 ((devel), go1.17.6, darwin/amd64)
OS
masOS 10.15.7
Docker version and image (if applicable)
No response
Steps to reproduce the problem
Create a test
Expected behaviour
The payload to the tested service looks like this:
Actual behaviour
The payload on a service looks like this:
The text was updated successfully, but these errors were encountered: