ixudra / curl

Custom PHP curl library for the Laravel 5 framework - developed by Ixudra
MIT License
561 stars 128 forks source link

Post Request not able to send #92

Closed chintanbanugaria closed 6 years ago

chintanbanugaria commented 6 years ago

Laravel 5.6 ixudra/curl : 6.16

My Issue is I am not able to send the POST request. I am getting blank response. GET request is working fine. Here's my code Curl::to('https://abc.com/getKey') ->withContentType('application/json') ->withHeaders(['header1:blah', 'header2:blah']) ->withData(['data1' => $blah, 'data2' => 'blah']) ->asJson() ->post(); I tried with traditional curl_init() method for post request and it was working fine.

Am I doing something wrong here ?

Thanks, Chintan

chintanbanugaria commented 6 years ago

Found the solution. I just removed the ->withContentType('application/json') and it worked like a charm.

Thanks,

elimentz commented 6 years ago

I was going to suggest the ->asJson() method, I think that also would have solved your problem. Glad it all worked out

chintanbanugaria commented 6 years ago

Yup. thanks. Awesome package BTW.

elimentz commented 6 years ago

Nice, glad you're enjoying it!