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:)
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!