Skip to content
Advertisement

cURL works for my REST API but Guzzle not

I am trying to connect my Laravel framework to my server using Guzzle. Every GET request without parameters but I have problems with POST.

This request using cURL works fine:

JavaScript

And this is what I have tried to implement with Guzzle:

JavaScript

When I make the request, I get the next error:

JavaScript

I think is something related to body but I don’t know how to solve it.

Any idea?

Advertisement

Answer

There’s no need to have the square brackets around the body value. Also, make sure there is an Accept header defined. You should use this instead:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement