Re: HTTP error 504 response not in JSON format

4350 0
Showing results for 
Search instead for 
Did you mean: 
10 - Mercury
10 - Mercury

As far as I can tell I aways get nice JSON responses, but with this error the response comes in the form of a HTML page. My error handling didn’t like that.

<!DOCTYPE html>
<h1 class="my2">This page is taking too long to load.</h1>

Is this intentional?

14 Replies 14
6 - Interface Innovator
6 - Interface Innovator

Hi Tuur,

No, it shouldn’t be like that. What client language/library are you using? Do you have the headers that you are sending? What’s in the content-type and accept headers?


The hard part is that it almost never happens of course, so it’s difficult to reproduce.

I’ll be back when I have more…

6 - Interface Innovator
6 - Interface Innovator

What are those headers for regular requests?


Generally Authorization & Content-Type (application/json) for Post / Patch (HTTP 1.1).

The reason I was asking is that I have a feeling it is related to attachments / photos fields and server-side time-outs only. So I was figuring it might have been some sort of internal error forwarding that’s not converted or something.

But the problem might just as well be me too of course. :slightly_smiling_face:

Anyway, I’ve added the Accept (application/json) now too. I’ll be back…

10 - Mercury
10 - Mercury

So rethinking about this all; you probably take my content type header for post & patch as the default for your response and since that hint is missing for the other requests (specifically ‘get’) I get HTML?

Yeah, that’s probably it. We only look at content-type and if it’s not set, you’d get HTML. GET requests may or may not include content-type as it should be sending no content. There was a recent patch for that to airtable.js.

I think we’ll need to change it to just never return HTML for Our API always returns JSON anyway.

I was lazily assuming that. And never noticed until I got timed out (which almost never happens).

Anyway, learned a couple of new things. Thanks for the help!

After adding the Accept header (to application/json) I’m still getting HTML with 504’s & 502’s. The weird thing is that sometimes the 502’s come in JSON. I’ve already double checked my code, but I’m pretty sure my calls are consistent.

Since these are both time-out errors could it be something in the processing (order?) on your side or can I try other headers / combinations?

<h1 class="my2">This page is taking too long to load.</h1>
<h3 class="quiet">Sorry about that. Please try refreshing and contact us if the problem persists.</h3>

I’ve noticed the order of setting the headers in my code is not consistent. Can’t phantom that could be a problem, but I’ve changed it anyway.

Small update: it’s still happening. And the exact same request is getting a JSON response with error 500 and HTML with a 504 so I think it’s something on your side…

Since these are all time out related maybe processing the response is not 100% completed as well?

Just FYI… :slightly_smiling_face:

Additional info: going through my log files I also found empty responses and a couple of

{"code": "timed_out"}

All with status 504.

I’ve long suspected something like this. I get strange errors when I create sync scripts that depend on results from Airtable. I have error handling coded in, however it seems that at times I get a result that isn’t an error yet isn’t expected content. Anyway, just chiming in so that I get pinged on updates to this thread. I guess I need to dial in my response-error-checking some more. Thanks Tuur for digging deeper!

My pleasure. :slightly_smiling_face: