Reputation: 1
controller PagesController
public function index()
{
$client = new Client();
$hospital_id = 37;
$res = $client->request('POST', 'http://vph.com/api/GetService'.$hospital_id,[
'form_params' => [
'body'=>$hospital_id
]
]);
i want to api hit but is not working
ERROR
Client error: `POST http://vpshealth.com/api/GetServiceList37` resulted in a `404 Not Found` response: <html> <head><title>404 Not Found</title></head> <body bgcolor="white"> <center><h1>404 Not Found</h1></center> <hr> (truncated...)
Upvotes: 0
Views: 63
Reputation: 1
$client = new \GuzzleHttp\Client();
$hospital_id = 37;
$response = $client->request("POST", "http://vpshealth.com/api/GetServiceList?hospital_id=".$hospital_id,
[
'json'=>['body'=>$hospital_id]
]);
$data=$response->getbody();
$data=json_decode($data);
dd($data);
solve
Upvotes: 0
Reputation: 129
missing / in the URL
url should be http://vph.com/api/GetService/'.$hospital_id
public function index()
{
$client = new Client();
$hospital_id = 37;
$res = $client->request('POST', 'http://vph.com/api/GetService/'.$hospital_id,[
'form_params' => [
'body'=>$hospital_id
]
]);
Upvotes: 1