Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting cURL error 3: <url> malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) error after saving models in laravel 5.4

I am having this error cURL error 3: <url> malformed (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) after saving/creating multiple models to database.

I have this in my controller:

public function storeTruck(Request $request){
    //Save Company Detail
    $company = Company::Create($request->only(['company']));
    // Save Trucker Info
    $request->request->add(['password'=>bcrypt('trucker')]);
    $request->request->add(['company_id'=>$company->id]);
    $trucker = Trucker::create( $request->only([
        'first_name','last_name','company',
        'email','contact', 'password', 'company_id'
    ]));
    return view('admin.truck.list'); 
}

Those models are saved successfully in database but it will then proceed to a cURL error 3 problem. What causes this error based on the codes? Please advice. Thanks.

like image 214
Jay Marz Avatar asked Jul 29 '17 18:07

Jay Marz


People also ask

How do I fix curl error 3?

The error curl: (3) URL using bad/illegal format or missing URL could be caused by a character issue with the passwords. Characters such as @ or & or other symbols may be problematic on the command line. To fix this issue, add double quotes around your URL.

Why is this URL malformed?

This violation indicates that a request that was not created by a browser, and does not comply with HTTP standards, has been sent to the server. This may be the result of of an HTTP request being manually crafted or of a client tunneling other protocols over HTTP.


2 Answers

I made a mistake when instantiating the the Guzzle Client Object:

Rather than assigning my baseUrl to th 'base_uri' key as below,

$client = new Client([
        'base_uri' => $this->baseUrl
    ]);

I assigned the $baseUrl to the 'base_uri' key, which does not exist.

$client = new Client([
        'base_url' => $this->baseUrl
    ]);

Be careful when doing this. make sure you use 'base_uri' instead of 'base_url.

like image 86
MT_Shikomba Avatar answered Oct 02 '22 21:10

MT_Shikomba


This error is due to the URL is not correct. Check the cURL error 3: check this link

like image 30
KPK Avatar answered Oct 02 '22 20:10

KPK