Following a redirect after a POST, curl changes the method to GET for status codes 301, 302 and 303, matching what browsers do and what the HTTP specification requires for 303. The body is discarded. An API call that returns 301 because of a missing trailing slash or an http to https upgrade therefore arrives at the real endpoint as a bodyless GET, and the server responds with a confusing 405 or an empty result.
Detect it with '-v' and look for the second request line, or with '-w "%{method} %{num_redirects}"'.
curl provides '--post301', '--post302' and '--post303' to keep the method and body across each of those codes. Status 307 and 308 preserve the method automatically and need no flag, which is why modern APIs use them. The better fix is usually to call the final URL directly, since a redirect on every API request doubles the round trips. Note that '-d' implies POST and sets Content-Type to application/x-www-form-urlencoded, so a JSON body needs an explicit content type header or the '--json' shortcut added in curl 7.82.0.