I try to follow godot documentation and implement function _ make_ post_ request. But result only shows null with response code returned 400. Anyone please help me.
My godot script:
func _make_post_request(url, data_to_send, use_ssl):
var query = JSON.print(data_to_send)
var headers = ["Content-Type: application/json"]
$HTTPRequest.request(url, headers, use_ssl, HTTPClient.METHOD_POST, query)
func _on_Button_pressed():
_make_post_request("http://localhost/buymall/site/test","hello world",true)
php script:
public function actionTest(){
$day = array(
"monday"=>"1",
"tuesday"=>"2",
"wednesday"=>"3",
"thursday"=>"4",
"friday"=>"5",
"saturday"=>"6",
"sunday"=>"7",
);
echo json_encode($day);
}
my return headers:
[Date: Wed, 25 Mar 2020 15:34:41 GMT, Server: Apache/2.4.41 (Win64) OpenSSL/1.1.1c PHP/7.3.11, X-Powered-By: PHP/7.3.11, Access-Control-Allow-Origin: http://mall.buymall.com.my, Set-Cookie: PHPSESSID=cldhaop58v2ajo0ebn6hq3b2r0; path=/, Expires: Thu, 19 Nov 1981 08:52:00 GMT, Cache-Control: no-store, no-cache, must-revalidate, Pragma: no-cache, Set-Cookie: current=*****************************************%3A3%3A%22web%22%3B; expires=Fri, 24-Apr-2020 15:34:41 GMT; Max-Age=2592000; path=/, Set-Cookie: YII_CSRF_TOKEN=54c897c15fba9d2ad4fad12ce7219d69f478a744s%3A88%3A%22NmlPMnJxZ1ZjRG1vOFZCcHdPejBuN01mNHRJRFk0UloxSdwtq6pnFwQEwKV1FgfENsT7rNs5xG6UwQMyVzs9Dw%3D%3D%22%3B; path=/, Connection: close, Transfer-Encoding: chunked, Content-Type: text/html; charset=UTF-8]