Timeline for 400 Bad Request - JavaScript App calling Custom wp-json endpoint
Current License: CC BY-SA 4.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 17, 2019 at 13:48 | vote | accept | wlh | ||
Sep 27, 2018 at 14:30 | answer | added | wlh | timeline score: 1 | |
Sep 27, 2018 at 14:23 | comment | added | Sally CJ | Ok, but maybe you should write an answer (and accept it), or update your question, so that people know the question has been answered. :) | |
Sep 27, 2018 at 14:09 | comment | added | wlh | Just found my problem. | |
Sep 27, 2018 at 14:04 | comment | added | wlh | Sure. I've added the JS I use to call the api | |
Sep 27, 2018 at 14:04 | history | edited | wlh | CC BY-SA 4.0 |
added more code
|
Sep 27, 2018 at 13:42 | comment | added | Sally CJ | "application on my wordpress site that calls this api" - is it possible for you to share the code the application uses when making the API request? | |
Sep 27, 2018 at 13:34 | comment | added | wlh | That's not the issue either. I tried what you said, same response, but I could also tell that from the lack of the full error (statusText, origin) in the logged error. The errors I define within my function include extra information so that I know the error is generated by a particular issue with the submitted data. Even so, I changed the 400 to 200 and still got the 400 error. | |
Sep 27, 2018 at 13:13 | comment | added | Sally CJ |
Then it shouldn't be a pre-flight issue. Perhaps the request body was empty or not a valid JSON string? See the is_null($data) in the proxy_data() function. Try temporarily change the $response->set_status(400); to $response->set_status(200); (or use another status other than 400 ).. and see if you get the 200 status. If yes, then the problem was probably with the request body.
|
|
Sep 27, 2018 at 12:49 | comment | added | wlh | @SallyCJ Yes. It persists. | |
Sep 27, 2018 at 5:29 | comment | added | Sally CJ |
What happens when you disable the handle_preflight() (comment out the add_action() )? Does the 400 error persist?
|
|
Sep 26, 2018 at 22:15 | review | First posts | |||
Sep 27, 2018 at 0:04 | |||||
Sep 26, 2018 at 22:12 | history | asked | wlh | CC BY-SA 4.0 |