GET - Response returns "Bad request 400" error

Hey there, i am trying to call a simple GET request, while passing “Header” attributes to the GET request. Without the “Header” attributes" i was getting “Forbidden 403” error.

Anyway, i am not able to somehow get a correct response.

Domain uses “cloudflare” so i am not sure, if this is the issue, or if my request is just not correct.

  *** Settings ***
    Library  RequestsLibrary

    *** Variables ***
    ${BASE_URL}    https://www.alza.sk

    *** Test Cases ***
    Check availability of GPU
        [Documentation]    Get response from Alza.sk
        Create Session    alza    ${BASE_URL}  
        ${DictBody} =    Create Dictionary    Host=https://www.alza.sk    User-Agent=Mozilla/5.0    Content-Type=application/json    Accept=*/*     Accept-Encoding=gzip, deflate, br    Connection=keep-alive
        ${RequestBody}=    GET    ${BASE_URL}    headers=${DictBody}

People / Companies use cloudflare to prevent scraping (amongst other things) so unless you are trying to automate something you work on - it’s going to be really tricky if not impossible to make it fool proof.

Anyway, error 400 indicates that your request is invalid and probably related to headers you provide. Id start debugging by this:

Make a request on browser that works
Make a request towards dummy http server like nc (netcat)
Diff the headers sent vs what your GET sent.

2 Likes