Skip to content

unable to get response form an API in Laravel [closed]

I am getting null response in laravel after dd(); ,however in Postman i am getting a response, maybe I am passing the wrong body to the API, kindly guide me on how to pass the following body to this API.

Thanks for your help.

This is my controller

public function callpdf(Request $req)
    // code...
    $host = new HostClass();
    $obj = new SessionClass();
    $response8 = Http::POST($host->getserverIp() . '/PDFReport',[
      // "patientId"=> $obj->getpatientId(),
      "reportId"=> "618",
      "departmentId"=> "128",
      "orderStatusId" => "12",
      "sessionId"=> "3",
    return $response8;

This is Postman request and response

       "patientId": "001000010818",
        "departmentId": "128",
        "con": "003001200326197",
        "odi": "2",
        "orderStatusId" : "12",
        "reportId": "618",
        "sessionId": "3"



I am getting null response in laravel after dd();, however in Postman i am getting a response

Based on your response to my question:

Is your callPdf method a web or api route? When using Postman, are you calling the API directly?

@Peppermintology it’s a web route, API is “PDFReport”

I would expect this behaviour. You’re using dd(); which is Laravels dump and die method. What this does is dump the data you provide it and then die which halts execution meaning nothing after the dd() is ever executed.

So your return statement is never executed, hence no response.

User contributions licensed under: CC BY-SA
1 People found this is helpful