This is an archived forum post. The information may be outdated. Contact us if you have any questions.

API returns status code 200 (incorrectly) when target URL returns 401

centi wrote on 2020-03-04:
Hi,

I'm trying to use your API to generate a PDF from a target URL, which is behind a HTTP Basic authorization. When the URL returns 401 as a status code (wrong username or password, etc), then I would expect the PdfCrowd API to return a 474 status code as specified in the documentation (https://pdfcrowd.com/api/status-codes/):

474
URL Load Error
The URL loaded with an HTTP code >= 400 or some requests are still pending. See details in a debug log.


But the API returns a 200 status code as if everything went well. The debug log also says that the status is "ok".

I've checked our apache access logs and the request did really return 401, so I'm sure that on our side everything is right.

Is there anything I can do, to make it work correctly?
support wrote on 2020-03-04:
Hi,

Pdfcrowd API doesn't check the status code by default.
Use API method setFailOnMainUrlError(true) or setFailOnAnyUrlError(true)