I'm using guzzle and laravel to call an API however when I get an error from the API, I can't view the error message sent back from the API. Laravel / Guzzle gives a default error Client error: 400.
How do I view the error message sent back?
I added this to the request which solved my issue.
'http_errors' => false
Related
i'm getting error while i'm calling simple post api and it throws 422 with 204. and in my code i used try and catch. it every time going to catch. i'm using laravel as a backend and vue.js 3 as a frontend. for api calling i'm using axios.
204 preflight error
I checked solutions in google but they all asking for sanctumn/csrf-cookie. but i'm not using sanctum in my current flow.
I have 2 servers which are API server and Client server ....
Both server using Google Cloud server and I use Laravel framework to develop my system...
So, currently the problem is, it return 403 error when calling API (to API server) using GuzzleHttp (from Client Server).....
But after I change the user agent to curl/7.65.3, suddenly it is working fine...
But I want to know why??? Is there any other solution without changing the user-agent???
Thanks
What is your use method? If GET you can refer to:
GET Requests That Include a Body
If a viewer GET request includes a body, CloudFront returns an HTTP status code 403 (Forbidden) to the viewer.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html
How to set Laravel to catch/log 500 errors from API?
I have Laravel 6.x and, in .env, I have APP_ENV=production with APP_DEBUG=false and a function with DB::table('table_doesnt_exists')->get().
If I access a web route from browser which call that function I see on the screen "500 Server Error" and the error is written in logs, which is perfect.
If use axios and call an API route which call the same function I only get HTTP response 500, without any response, and most important there is no error in logs.
I have manage to make it works after trying multiple combinations.
APP_ENV=local
APP_DEBUG=false
The error is written in logs and the API only return
{ message: "Server Error" }
I am implementing laravel api with 'api_token' method.
API working fine in POSTMAN REST CLIENT and core php curl request.
But i tried to get response in laravel app using Guzzle Http client and native curl method. Both request returns 401 unauthenticated. i used same api_token which i was used to test in postman rest client. Any idea?
Note: Its not a CORS problem.
Its happen because of app cache.
Just cache:clear and config:cache will resolve this problem!
I'm working with laravel and I have done login with Google in laravel using socialite. Now I'm trying to get google contacts and I'm using Artdarek\OAuth for this. But I'm getting an error
TokenResponseException in StreamClient.php line 68: Failed to request resource. HTTP Code: HTTP/1.1 400 Bad Request
here is error screen shot
I also tried many links, but I don’t know what’s problem with my code.