Hi all... i am using robot frame work for API testing using RequestsLibrary.. but i am facing below issue: 1. when comparing status code the argument type is not matching for ${resp.status_code} with 200 i.e: Should Be Equal As Strings ${resp.status_code}, 200 Argument types are: <type 'int'> <type 'unicode'> 2. While i am doing POST request i am getting status code : 415 RequestsLibrary . Post Request URLP, /tsws/api/v1.0/messages/, ${header}
please help ...!!!!!! |
*** Settings ***Library RequestsLibrary
*** Test Cases ***Get Cookies Create Session google http://www.google.com ${resp}= Get Request google / ${cookies}= Create List @{resp.cookies} Log ${cookies}
Set Cookies ${cookies}= Create Dictionary cookie_id cookie value Create Session httpbin https://httpbin.org cookies=${cookies} debug=1 disable_warnings=1 ${resp}= Get Request httpbin /cookies Log ${resp.text}
${resp}= Post Request you_session_alias uri headers=${your_header_dictionary} data=${your_data_dictionary}
Hi,
I am also stuck with the Post request keyword for testing REST API. What is the correct way to pass the raw body content to the post request?
request raw body :
{
"username": "",
"password": "",
"mobile_id": ""
}
I tried in 2 ways.
1. Using Get File – passing the .json file
2. Using Create Dictionary – passing the body as key value pairs(see the screenshot below)
And I get the following Error :
Starting test: Robot.REST TEST.swaggerpost
INFO : ${headers} = {u'content-type': u'application/json'}
INFO : Creating Session using : alias=swagger, url=https://eco-test.nyon-test.de/ebikeconnect/api/app/token/public, headers={u'content-type': u'application/json'}, cookies=None, auth=None, timeout=None, proxies=None, verify=False, debug=0
INFO : ${data} = {u'username': '', u'password': u'', u'mobile_id': u''}
WARN : Deprecation Warning: Use Post Request in the future
INFO : C:\Python27\lib\site-packages\urllib3\connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecureRequestWarning)
INFO : ${resp} = <Response [400]>
INFO : {"errors":[{"code":0,"message":"Error; javax.ws.rs.WebApplicationException: ebikeapi.exception.ServiceException: Invalid JSON format (caused by) ebikeapi.exception.ServiceException: Invalid JSON format (caused by) com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 9 (caused by) java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 9"}]}
FAIL : 400 != 200
Ending test: Robot.REST TEST.swaggerpost
I guess the request does not take the raw body and so the test gets failed.
Can anyone tell me if I have passed the arguments correctly into the POST request?
And also, How can I see the actual json response body?
Actual response body :
{
"token_value":
"mobile_id":
"valid_until":