I try to call a POST API, however in the log it tells me that it changes to GET, that’s why it shows me a 405 result code. I don’t understand why I send my request type POST.
Hello and welcome to the forum!
It’s difficult to ascertain the cause just from this screenshot. k6 should definitely be trying to make a POST request with that code, in any case.
- What are the request headers that are being printed to the console? (just need to scroll up a bit) - you should see
POST <url-path>/ HTTP/1.1(assuming this is using HTTP/1.1, of course)
- Are there any preceding requests, in other words, could the error actually be happening as a result of an earlier request?
- Although a server should only be sending a 405 response if it didn’t like the request method used by the client, web developers do have some freedom over what status code to send back, and so you might be receiving inaccurate guidance on what is wrong with the request (the amount of times I’ve seen this… ). Given that you are sending JSON in the request body, it might be an idea to add the
Content-Typeheader specifying that (if you haven’t already - I can’t see what
header1is set to), in other words, try adding
Content-Type: application/jsonas the server may be expecting it (happens a lot)
Hope that helps.