Im gonna make this brief;
Im using wp_remote_post to do a POST request to an external API. My local development environment looks something like “http://website.test”. As of now I am requesting to a QA version of this API so the protocol of the endpoints is HTTP. The problem is that the $response object always returns an empty body. If I copy the exact request JSON that im sending over, and the exact HTTP URL of the API, and use it on Postman, I get a normal body response with no issues. So why is the wp_remote_post giving me an empty body?
This is how im doing the request:
I’m assuming it could have something to do with the fact that its not over HTTPS (neither my local environment, nor the API, but as I said, it works as intended on Postman). I already tried the “blocking” and the “sslverify” options.
Another theory that I have is that it might have something to do with the request body that I am sending over. This is because I am using other endpoints of the same API over HTTP, and some of them DO send a non-empty body back. The pattern that I noticed is that the endpoints that do return a body are the endpoints on which I send an array like this:
A simple array with one index that contains an array seems to work. But when I send something like this:
This one seems to get back an empty body.
I know that my two theories are extremely different, but at this point any kind of insight would be of great help. As I said, what throws me off is that the same request body that gets an empty response body with wp_remote_post, when used on Postman, it does get a non-empty , valid response body, so it couldnt possibly be the API, right?
Anyways, thank you for your time and I hope I made my issue clear.
- Hiện tại chúng tôi có hơn 25 nghìn bài văn mẫu các thể loại.
- Kho tài liệu, đề thi học sinh giỏi các lớp vô cùng phong phú.
- Mỗi ngày cập nhật hơn 100 đề thi chất lượng từ các website bán tài liệu lớn.
Tải đề thi VIP với giá siêu rẻ tại Vip.Dethihsg247.Com