"The requested resource does not support http method 'GET' " despite using POST On Session

I’m trying to use ‘POST On Session’ to submit headers and Post Data to a custom API I made in order to get a specific response about one “user” (headers used for access and post data used for the specific information I want). However, when running the test, I get as an error that the server doesn’t support the GET method, even though that’s not what I am using (or at least intend to use). I have already coded an “API call” in C# to the server using and IDE, so I’m sure that it’s possible to post data to the API and get the response I want. I’ll link the code below, as well as my file structure and a screenshot of the error message my API gives me. I’ll also write what error code my terminal in VSCode gives me when I run the test. I’m relatively new to robot framework so if you need any other info in order to answer my question, or if I didn’t explain very well and you need clarification, I’ll try my best to answer it.

The robot’s code:

***Settings***
Library    RequestsLibrary
Library    JSONLibrary
Library    Collections

***variables***
${API_BASE_URL}                    http://localhost:59856
&{headers} =
...    CallerPartyServiceId=Kjg730-hvxwi09
...    ApplicationKey=Testkey
&{PostData} =
...    PartyServiceId="85793-3950-0500053"    
...    Areas=all

***Test Cases***

Retrieve User Data
    Create Session        api_session          ${API_BASE_URL}
    ${response} =         POST On Session      api_session        /api/'api_name'/GetInfoByPartyServicveId      headers=& {headers}    data=&{PostData}
    ${json_response} =    Set Variable                            ${response.content.json()}
    Should Be Equal       ${json_response}                        {json_expected\\expected_result.json}
    Log To Console        ${json_response}

File Structure:
The actual robot:
C:\Robot-projects\MyAPITest\tests\APITest.robot
Comparing json tool:
C:\Robot-projects\MyAPITest\tests\json_expected\expected_result.json

Error codes:

(Error code in the VSCode terminal:)
Retrieve User Data | FAIL |
HTTPError: 500 Server Error: Internal Server Error for url: http://localhost:59856/api/

(Server Error code at the URL:)
image_2025-06-05_145500469

If you need, I could also provide the API call I made using JetBrains Rider just to show what works and what I want. Unfortunately though, I won’t post any screenshots and such of the API itself, because I would rather not. Thanks for any help at all!

If you run your suite with TRACE level enabled, you may be able to see what the request was that RequestsLibrary “send over the line”. If you’re using RobotCode and have it configured to attach to the Python process, you could also put a breakpoint within the RequestsLibrary to check, although I’m fairly certain you’ll find that the http request being made is in fact a POST request.

Do you have access to trace logs from the actual API you’re sending the request to? I have a hunch that it’s actually an internal call that the API is trying to make that fails. I believe so since you’re getting a 500 response (internal server error, not client error) instead of an http 405: Method Not Allowed.

I wouldn’t be surprised that something in your POST request isn’t quite as expected, but that the API server handles it quite poorly, resulting in a cryptic / misleading error message.

1 Like

Thanks, I looked at my API logs and turns out one of my headers was being handled wrong. That helped a lot!