We already solved the issue.
What we did:
1. Checked if all the setup/configuration is correct on the Moodle site.
2. Checked the connection via hard request URL: https://[moodlesitehere]/webservice/rest/server.php?wstoken=[token-here]&wsfunction=core_course_get_courses&moodlewsrestformat=json
3. Checked the connection from a test page within our site using WordPress function.
wp_remote_get( $request_url ); //request url above mentioned
4. Checked if the server was blocking our request. Contacted server support team as well.
5. Checked if our site is able to find moodle hosted site via the curl request provided above
6. Checked if we can get the connection successfully via a different server
Result
Moodle configuration were all correct, We did received data via the raw request URL but a 404 error via wp_remote_get(), Server support team said there were no recorded blocks on the server, curl test was successfull and We could connect successfully from a different server. There was a messsage from the error log which say client denied by server configuration
Conclusion
Our test directed us towards the core server environment and because we could connect via direct url and even from a different server, we thought our Moodle site and our main site (both hosted on the same server but different domain) config was not the problem at all. Turns out there is this web-server configuration issue which was blocking our GET/POST request.
Allowing GET, POST, PUT and DELETE requests through the .htaccess (web-server configuration) file of moodle.yoursite.com website did the magic here.
<Limit GET POST PUT DELETE>
order deny,allow
allow from all
</Limit>
I wonder why we were able to connect via different server but not via this same server where the Moodle site was hosted. I believe the GET/PUT request permission within the server was different than for a request from a different server.
Hope this will be helpful for plugin development and many other users experiencing similar problems in the future.