Skip to content
Advertisement

Guzzle throws 401 or 406 exception

cURL works fine:

JavaScript

Guzzle does not:

JavaScript

This responds with a 401 error: not authorized. This is my first time using Guzzle but in my searches I haven’t seen this error. Seems like a simple request so I’m not sure why it is failing.

Thank you!

Advertisement

Answer

I had to add another header to explicitly tell it to handle json

JavaScript

Thank you for pointing out that the 401 was a false error – the real error was the 406, which made me read how to actually fix that.

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