10

So I spent the last 2 hours trying to figure out why my co-workers source when hitting the API I built was not working. They kept saying that the problem was the API and I kept saying that it's their implementation.

Turns out it was their implementation and as well as the API. Their implementation problem was not setting the "Accept" in the header. The API problem is how Laravel will return a JSON error response ONLY IF the "Accept" is set in the header.

I actually documented this into the API documentation but it's obvious that none of my co-workers read that you need to set the headers correctly. I think the more scary thing is that they didn't know the difference between Accept and Content-Type!!

Comments
  • 1
    Oh, never fiddled with Accept before, but it looks nice! Isn't there an option for default if no Accept is given? Like horrendous ASCII art text? 😅
  • 1
    @psukys You mean for Laravel? No since this is a part of it's core exception handling. Any kind of request that is not expecting JSON will send a 50x template as it's default.
  • 0
    So the problem is not on your API. The client is responsible for telling the server what kind of content it expects. The server can only make a guess if the client doesn't specify, and a 5xx HTML template is as good a guess as any other.
  • 0
    @ethernetzero absolutely true. But my point is that my co-workers just can't seem to figure out things on their own. They come to me for help, even though I have no idea what their implementation is like.
  • 0
    @IdolWotaP Do they always start by saying only “this doesn't work” and leave you to figure out what exactly is “this” and which one of the thousands of ways a thing can “not work” is the way that particular thing doesn't work?

    I've had to formulate that question many times in the exact same way I wrote it above. Your coworkers seem to be like that kind of people.
  • 0
    @ethernetzero well they do at least explain the problem. It's more of the problem that they don't read/research stuff. And when I do explain stuff they just seem to remember or take it in. I think this stems from the fact that they've been doing the same thing for so long they just can't learn.
  • 0
    @IdolWotaP Well, if they at least make that effort then maybe they're not lost. Let's hope their inability to learn erosionates over time, hopefully soon enough.
Add Comment