No resource method found for GET, return 405 with Allow header

Hi Guys,

I am trying to test some microservices and first I need to get new token from the Keycloak server and when I am trying to run the below “keyword” I am getting the error: “No resource method found for GET, return 405 with Allow header”, but I don’t have any GET method on my keyword.

A valid token for "${client}" with secret "${client_secret}"
    ${auth} =    Create List    ${client}    ${client_secret}
    ${headers_dict} =    Create Dictionary    Content-Type=application/x-www-form-urlencoded    Accept=application/json
    ${data_dict} =    Create Dictionary    grant_type=client_credentials
    Create Session    req    http://keycloak.${domain}    auth=${auth}
    ${resp}=    POST On Session    req    /auth/realms/gdp/protocol/openid-connect/token    headers=${headers_dict}    data=${data_dict}
    Should Be Equal As Strings    ${resp.status_code}    200
    ${token}=    catenate    Bearer    ${resp.json()}[access_token]
    Set Suite Variable    ${EX_TOKEN}    ${token}
    Log    ${EX_TOKEN}

output.log result:

Documentation:	
Sends a POST request on a previously created HTTP Session.

Start / End / Elapsed:	20240307 18:41:44.856 / 20240307 18:41:45.699 / 00:00:00.843
18:41:45.683	INFO	POST Request : url=http://keycloak.domain/auth/realms/gdp/protocol/openid-connect/token (redirected) 
 path_url=/auth/realms/gdp/protocol/openid-connect/token 
 headers={'User-Agent': 'python-requests/2.31.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'Connection': 'keep-alive', 'Content-Length': '94', 'Authorization': 'Basic YWxhcssdfsdfsdfsdfsdfwerqwrqweqweqweqweqeqweqqwsaWVudC1zZWNyZXQ='} 
 body={'grant_type': 'client_credentials'} ['client', 'client-secret'] 
 	
18:41:45.683	INFO	GET Response : url=keycloak.domain/auth/realms/gdp/protocol/openid-connect/token 
 status=405, reason=Method Not Allowed 
 headers={'x-xss-protection': '1; mode=block', 'x-frame-options': 'SAMEORIGIN', 'referrer-policy': 'no-referrer', 'date': 'Thu, 07 Mar 2024 16:41:46 GMT', 'strict-transport-security': 'max-age=31536000; includeSubDomains', 'x-content-type-options': 'nosniff', 'content-type': 'application/json', 'content-length': '90', 'x-envoy-upstream-service-time': '2', 'server': 'istio-envoy'} 
 body={"error":"RESTEASY003650: No resource method found for GET, return 405 with Allow header"}

You are trying to get authenticated session with a token to work over HTTP (not encrypted) and backend tells you you thats not allowed - i wonder why :smiley:

Maybe change the url to HTTPS (encrypted) where you create the session ?

Reason for GET most likely could be that the response to POST will also return a redirect header that requests library will obey .

2 Likes

yes, right, i am an idiot. Thanks a lot

1 Like