Question

App Platform gives 400 Bad Request (cloudflare) error with PATCH requests

Posted February 1, 2021 1.2k views
DigitalOcean App Platform

Hi!

My Django app running on App Platform gives 400 Bad Request errors when making PATCH requests. It does work when I change it to PUT.

I noticed cloudflare below the message. Anyone knows if Cloudflare disallows certain requests?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
1 answer

CloudFlare should properly pass an HTTP PATCH request. HTTP PATCH requests should have a request body, is it possible that your request is missing a body?

If you’re still having trouble, could you either post here (or contact support) the request header and body you’re using in your request.

  • Thanks for answering so fast!

    I think it’s sending a request body. It should, because locally (docker/nginx/django) it works too.

    Here’s the request as a curl command + response:

    curl 'https://xxxxxxxxxxxx-m53sa.ondigitalocean.app/api/xxxxxxxx/1/' \
      -i -X 'patch' \
      -H 'authority: xxxxxxxxxxxx-m53sa.ondigitalocean.app' \
      -H 'pragma: no-cache' \
      -H 'cache-control: no-cache' \
      -H 'sec-ch-ua: "Chromium";v="88", "Google Chrome";v="88", ";Not A Brand";v="99"' \
      -H 'dnt: 1' \
      -H 'accept-language: en,nl;q=0.9,nb;q=0.8,ar;q=0.7,de;q=0.6,en-US;q=0.5' \
      -H 'sec-ch-ua-mobile: ?0' \
      -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36' \
      -H 'content-type: application/json' \
      -H 'accept: application/json' \
      -H 'x-csrftoken: xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX' \
      -H 'origin: https://xxxxxxxxxxxx-m53sa.ondigitalocean.app' \
      -H 'sec-fetch-site: same-origin' \
      -H 'sec-fetch-mode: cors' \
      -H 'sec-fetch-dest: empty' \
      -H 'referer: https://xxxxxxxxxxxx-m53sa.ondigitalocean.app/editor/features/' \
      -H 'cookie: __cfduid=xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX; csrftoken=xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX; sessionid=xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX' \
      --data-raw '{"features":[{"id":1609186796562,"title":"Overdracht","feature_fields":[{"id":1609186862804,"key":"Vraagprijs","value":"€ ---- k.k."},{"id":1609186869959,"key":"Status","value":"Beschikbaar"}]},{"id":1609186801398,"title":"Bouw","feature_fields":[{"id":1609186890119,"key":"Soort woonhuis","value":"..."},{"id":1609186900570,"key":"Soort bouw\t","value":"Bestaande bouw"},{"id":1609186905949,"key":"Bouwjaar","value":"..."},{"id":1609186926828,"key":"Soort dak\t","value":"..."},{"id":1609187074026,"key":"Keurmerken","value":"..."}]},{"id":1609186824823,"title":"Oppervlakte en inhoud","feature_fields":[{"id":1609186952829,"key":"Woonoppervlakte","value":"... m2"},{"id":1609186961885,"key":"Gebouwgebonden buitenruimte\t","value":"... m2"},{"id":1609188292135,"key":"Inhoud","value":"... m3"}]},{"id":1609186990393,"title":"Indeling","feature_fields":[{"id":1609187097607,"key":"Aantal kamers\t","value":"? (? slaapkamers)"},{"id":1609187105516,"key":"Aantal badkamers\t","value":"? badkamer"},{"id":1609187112300,"key":"Badkamervoorzieningen","value":"?"},{"id":1609187118993,"key":"Aantal woonlagen\t","value":"? woonlagen"},{"id":1609187126082,"key":"Voorzieningen","value":"?"}]},{"id":1609186994071,"title":"Energie","feature_fields":[{"id":1609187061179,"key":"Voorlopig energielabel\t","value":"?"},{"id":1609189202095,"key":"Oud label","value":"?"}]},{"id":1609187003579,"title":"Kadastrale gegevens","feature_fields":[{"id":1609187063238,"key":"Oppervlakte","value":"? m2"}]},{"id":1609187011643,"title":"Buitenruimte","feature_fields":[{"id":1609187065017,"key":"Ligging","value":"..."}]},{"id":1609187017349,"title":"Bergruimte","feature_fields":[{"id":1609187277307,"key":"Schuur/berging\t","value":"..."}]},{"id":1609187022343,"title":"Parkeergelegenheid","feature_fields":[{"id":1609187227694,"key":"Soort parkeergelegenheid\t","value":"..."}]},{"id":1609263094635,"title":"Garage","feature_fields":[{"id":1609263101711,"key":"Inhoud","value":"? m3"}]}]}' \
      --compressed
    HTTP/2 400
    server: cloudflare
    date: Mon, 01 Feb 2021 18:18:33 GMT
    content-type: text/html
    content-length: 155
    cf-ray: -
    
    <html>
    <head><title>400 Bad Request</title></head>
    <body>
    <center><h1>400 Bad Request</h1></center>
    <hr><center>cloudflare</center>
    </body>
    </html>
    

    thanks again!

    • Hi, I am experiencing the same issue. Did you ever find a solution for this?

      Originally, had an empty body. I changed to use the body instead of route parameters and I still get the same response.