asyrjasalo / restinstance Goto Github PK
View Code? Open in Web Editor NEWRobot Framework library for RESTful JSON APIs
Home Page: https://asyrjasalo.github.io/RESTinstance
License: GNU Lesser General Public License v3.0
Robot Framework library for RESTful JSON APIs
Home Page: https://asyrjasalo.github.io/RESTinstance
License: GNU Lesser General Public License v3.0
This very simple GET test fails in Windows10 (Python 2.7.15) but it works with Ubuntu 16.04 (Python 2.7.12).
Fails in Windows with SchemaGenerationError: Could not find matching type for object: 1536489510350L
Test was run in virtualenv in both systems and following packages were only installed by pip:
Test uses Liikennevirasto's open api to get the vessel location --> Can be easily tested with Curl or with browser:
curl -X GET --header 'Accept: application/json' 'https://meri.digitraffic.fi/api/v1/locations/latest/230629000'
Test case:
*** Settings ***
Library REST https://meri.digitraffic.fi
*** Test Cases ***
Get
Set Headers {"Accept":"application/json;charset=UTF-8","User-Agent":"curl/7.47.0"}
REST.Get /api/v1/locations/latest/230181000 validate=true
Traceback:
Traceback (most recent call last):
File "C:\temp\testi\lib\site-packages\REST\keywords.py", line 145, in get
return self._request(endpoint, request, validate)['response']
File "C:\temp\testi\lib\site-packages\REST\keywords.py", line 494, in _request
instance = self._instantiate(request, response, validate)
File "C:\temp\testi\lib\site-packages\REST\keywords.py", line 517, in _instantiate
schema['response']['body'] = self._new_schema(response['body'])
File "C:\temp\testi\lib\site-packages\REST\keywords.py", line 553, in _new_schema
builder.add_object(value)
File "C:\temp\testi\lib\site-packages\genson\schema\builder.py", line 64, in add_object
self._root_node.add_object(obj)
File "C:\temp\testi\lib\site-packages\genson\schema\node.py", line 50, in add_object
schema_generator.add_object(obj)
File "C:\temp\testi\lib\site-packages\genson\schema\generators\object.py", line 56, in add_object
self._properties[prop].add_object(subobj)
File "C:\temp\testi\lib\site-packages\genson\schema\node.py", line 50, in add_object
schema_generator.add_object(obj)
File "C:\temp\testi\lib\site-packages\genson\schema\generators\array.py", line 42, in add_object
self._items.add_object(item)
File "C:\temp\testi\lib\site-packages\genson\schema\node.py", line 50, in add_object
schema_generator.add_object(obj)
File "C:\temp\testi\lib\site-packages\genson\schema\generators\object.py", line 56, in add_object
self._properties[prop].add_object(subobj)
File "C:\temp\testi\lib\site-packages\genson\schema\node.py", line 50, in add_object
schema_generator.add_object(obj)
File "C:\temp\testi\lib\site-packages\genson\schema\generators\object.py", line 56, in add_object
self._properties[prop].add_object(subobj)
File "C:\temp\testi\lib\site-packages\genson\schema\node.py", line 49, in add_object
schema_generator = self._get_generator_for_object(obj)
File "C:\temp\testi\lib\site-packages\genson\schema\node.py", line 114, in _get_generator_for_object
return self._get_generator_for_('object', obj)
File "C:\temp\testi\lib\site-packages\genson\schema\node.py", line 146, in _get_generator_for_
kind, schema_or_obj))
Hi @asyrjasalo
At work i am currently facing some problems with your library. I found out after a post request to our internal rest interface a 200 OK was responded with an empty body { }. This is of course also a defect on our side but leads to an error in robotframework:
KeyError: u'properties'
Traceback (most recent call last):
File "C:\Anaconda3\envs\py2_automation\lib\site-packages\REST\keywords.py", line 404, in post
return self._request(endpoint, request, validate)['response']
File "C:\Anaconda3\envs\py2_automation\lib\site-packages\REST\keywords.py", line 1229, in _request
instance = self._instantiate(request, response, validate)
File "C:\Anaconda3\envs\py2_automation\lib\site-packages\REST\keywords.py", line 1257, in _instantiate
self._add_defaults_to_schema(schema, response)
File "C:\Anaconda3\envs\py2_automation\lib\site-packages\REST\keywords.py", line 1293, in _add_defaults_to_schema
self._add_property_defaults(body, schema['properties'])
I changed the code locally to test if this is working,..
in keywords.py, line 1289
def _add_defaults_to_schema(self, schema, response):
body = response['body']
schema = schema['properties']['response']['properties']['body']
if isinstance(body, (dict)):
self._add_property_defaults(body, schema['properties'])
this was changed to
def _add_defaults_to_schema(self, schema, response):
body = response['body']
schema = schema['properties']['response']['properties']['body']
# also check if dictionary is empty
if isinstance(body, (dict)) and not bool(dict):
self._add_property_defaults(body, schema['properties'])
in case of empty body.
How do you think about it?
BR
Kev
I looked at the code and it seems impossible to use Delete with a body:
def delete(self, endpoint, timeout=None, allow_redirects=None, validate=True):
With odata-based services, it is common to have endpoints with the following character:
/entity('A123')
I have made swagger documentation for this endpoint, but RESTinstance gives an incorrect error that this path is not found:
test | FAIL |
u'request':
- 'path':
- "No paths found for /entity('A123')"
I am under the impression that this has to do with the fact that the endpoint contains parentheses.
Here follows an example to reproduce this problem:
Swagger documentation: api-docs.json
{
"info": {
"title": "Test API",
"version": "1"
},
"basePath": "/api/v1",
"swagger": "2.0",
"paths": {
"/entity('{name}')": {
"get": {
"summary": "get odata endpoint",
"parameters": [
{
"in": "path",
"name": "name",
"type": "string",
"required": true,
"description": "Name"
}
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "success"
}
}
}
}
},
"definitions": {},
"responses": {},
"parameters": {},
"securityDefinitions": {}
}
Robot Framework test
*** Settings ***
Library REST url=https://host/ spec=./api-docs.json
*** Test Cases ***
test
REST.Get /api/v1/entity('A123')
Written in Robot Framework
The /users/1 name field contains "Leanne Graham"
String Field Partial
[Documentation] Check if a field contains a part of a string
... can use many strings in @{text} separated by two spaces
[Arguments] ${field_name} @{text}
${string} String response body ${field_name}
Should Contain Any ${string} @{text}
In a test case
[Tags] partial-string
GET /users/1
Validate.String Field partial name Lea rrggrgr Lxxel street city **PASS**
String name Lea **FAIL**
String name Lea rrggrgr Lxxel street city **FAIL**
Adding a support for loading YAML files for openapi/swagger spec would be a nice enhancement.
the docker command
docker run --rm -ti --env HOST_UID=$(id -u) --env HOST_GID=$(id -g) \
--env HTTP_PROXY --env HTTPS_PROXY --network host \
--volume "$PWD/tests":/home/robot/tests \
--volume "$PWD/results":/home/robot/results \
asyrjasalo/restinstance tests
fails and it is expected if the test docker images (mountrest... )are not also launched but this is not clear in the readme.
I get error below when I try to run the default tests.
Successfully built 6e24adbcd6c5
chown: /home/robot/results: Permission denied
chown: /home/robot/tests: Permission denied
[ ERROR ] Unexpected error: PermissionError: [Errno 13] Permission denied: '/home/robot/tests'
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/robot/utils/application.py", line 83, in _execute
rc = self.main(arguments, **options)
File "/usr/local/lib/python3.6/site-packages/robot/run.py", line 439, in main
settings['Extension']).build(*datasources)
File "/usr/local/lib/python3.6/site-packages/robot/running/builder.py", line 70, in build
return self._parse_and_build(paths[0])
File "/usr/local/lib/python3.6/site-packages/robot/running/builder.py", line 77, in _parse_and_build
suite = self._build_suite(self._parse(path))
File "/usr/local/lib/python3.6/site-packages/robot/running/builder.py", line 86, in _parse
extensions=self.extensions)
File "/usr/local/lib/python3.6/site-packages/robot/parsing/model.py", line 47, in TestData
extensions)
File "/usr/local/lib/python3.6/site-packages/robot/parsing/model.py", line 227, in populate
warn_on_skipped, extensions, recurse)
File "/usr/local/lib/python3.6/site-packages/robot/parsing/populators.py", line 112, in populate
include_suites)
File "/usr/local/lib/python3.6/site-packages/robot/parsing/populators.py", line 167, in _get_children
incl_suites):
File "/usr/local/lib/python3.6/site-packages/robot/parsing/populators.py", line 179, in _list_dir
names = os.listdir(unic(dir_path))
Please generate keyword documentation with libdoc (http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#libdoc) for the library, thanks
Hi Team,
I am exploring RESTinstance, no prior experience in API test using Robot Framework so facing problem to get response i.e. authentication key and get other response and store in a variable.
Below is my dummy code .. it is not confidential:
*** Settings ***
Library REST https://xxxxxxxxxxxxxxx.in/
Suite Setup Set Expectations
*** Keywords ***
Set Expectations
Expect response {"status":{"enum":[200, 201, 204, 401,405, 500]}}
Expect response {"seconds":{"maximum":1.5}}
*** Variables ***
${json} { "email": "[email protected]", "password": "password" }
*** Test Cases ***
POST with valid params to create a user
POST /api-token-auth/ ${json}
Integer response status 200
#[Teardown] Output file_path=${OUTPUTDIR}/inst.json
Output response body
Can you please help correct me, as I am not understanding how to implement.
and one more thing, I want to get a response from one request and from that response few information need to pass on to another request body. How can I do that?
Post /template/ ${CURDIR}/resources/fixtures/template/template.xml
throws
ScannerError: mapping values are not allowed here
in "/home/robot/tests/resources/fixtures/template/template.xml", line 833, column 47
Traceback (most recent call last):
File "/home/robot/src/REST/keywords.py", line 398, in post
request['body'] = self.input(body)
File "/home/robot/src/REST/keywords.py", line 993, in input
return self._input_json_from_file(what)
File "/home/robot/src/REST/__init__.py", line 288, in _input_json_from_file
return load_yaml(file)
File "/usr/local/lib/python3.6/site-packages/yaml/__init__.py", line 72, in load
return loader.get_single_data()
File "/usr/local/lib/python3.6/site-packages/yaml/constructor.py", line 35, in get_single_data
node = self.get_single_node()
File "/usr/local/lib/python3.6/site-packages/yaml/composer.py", line 36, in get_single_node
document = self.compose_document()
File "/usr/local/lib/python3.6/site-packages/yaml/composer.py", line 58, in compose_document
self.get_event()
File "/usr/local/lib/python3.6/site-packages/yaml/parser.py", line 118, in get_event
self.current_event = self.state()
File "/usr/local/lib/python3.6/site-packages/yaml/parser.py", line 193, in parse_document_end
token = self.peek_token()
File "/usr/local/lib/python3.6/site-packages/yaml/scanner.py", line 128, in peek_token
self.fetch_more_tokens()
File "/usr/local/lib/python3.6/site-packages/yaml/scanner.py", line 220, in fetch_more_tokens
return self.fetch_value()
File "/usr/local/lib/python3.6/site-packages/yaml/scanner.py", line 576, in fetch_value
self.get_mark())
template.xml", line 833, column 47
<items id="comment">For example: the reason for the cancellation or suspension of the service.</items>
... I know this libary is for JSON API ... but anyway ... you can't image what people use it for 😆
Can "the scanner" be turned off by some option switch?
I'm going to parse the requests as well as inputted json file to compare the content.
Thanks,
Doanh Nguyen
When attempting to use the POST keyword to authenticate into an endpoint that doesn't have the same domain certificate, I am unable to disable the SSL validation for a successful login. I've tried to use POST without validate=False
, but that fails with the domain error. Please advise.
Error message
This is not a JSON boolean:
False
Example usage below
*** Settings ***
Library REST https://example.com
*** Test Cases ***
Test Example
Set Headers { "username": "atenEmp1", "password": "qatest1" }
POST /user/login body={ "username": "user1", "password": "test1" } validate=False
Output response
Integer response status 200
The test case failed when validating response json schema, the get request succeed and get response, but I can't get the 'Output' in teardown stage to debug issue.
*** Test Cases ***
Get List
[Setup] Expect response ${CURDIR}/data/list.json
GET /api/list
[Teardown] Output
Result:
Get Position Template List | FAIL |
1 is not one of [0]
Failed validating 'enum' in schema['properties']['status']:
{'enum': [0], 'type': 'integer'}
On instance['status']:
1
Also teardown failed:
No instances: No requests made, and no previous instances loaded in the library import.
------------------------------------------------------------------------------
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
I have a curl example of a POST request which is working just fine in the terminal
curl -X POST \
-d "client_id=admin-cli" \
-d "username=admin" \
-d "password=admin" \
-d "grant_type=password" \
"http://localhost:8080/auth/realms/master/protocol/openid-connect/token"
Response is a (looooong) JSON string (shortend here)
{"access_token":"eyJhbGciOiJSUzI1NiIsInR5c...","token_type":"bearer"}
*** Settings ***
Library REST url=http://localhost:8080/auth # ssl_verify=false
*** Test Cases ***
Give me an admin Token
# Set Headers {"Content-Type": "application/x-www-form-urlencoded"}
POST /realms/master/protocol/openid-connect/token {"grant_type": "password", "client_id": "admin-cli", "username": "admin", "password": "admin"}
Output
Result of Output:
The instance as JSON is:
{
"request": {
"method": "POST",
"url": "http://localhost:8080/auth/realms/master/protocol/openid-connect/token",
"scheme": "http",
"netloc": "localhost:8080",
"path": "/auth/realms/master/protocol/openid-connect/token",
"query": {},
"body": {
"grant_type": "password",
"client_id": "admin-cli",
"username": "admin",
"password": "admin"
},
"headers": {
"Accept": "application/json, */*",
"Content-Type": "application/json",
"User-Agent": "RESTinstance/1.0.0rc2",
"grant_type": "password"
},
"proxies": {},
"timeout": [
null,
null
],
"cert": null,
"sslVerify": true,
"allowRedirects": true,
"timestamp": {
"utc": "2018-10-16T20:46:39.024490+00:00",
"local": "2018-10-16T22:46:39.024490+02:00"
}
},
"response": {
"seconds": 0.006259000000000001,
"status": 400,
"body": {
"error": "invalid_request",
"error_description": "error_description": "Missing form parameter: grant_type"
},
"headers": {
"Connection": "keep-alive",
"Cache-Control": "no-store",
"Pragma": "no-cache",
"Content-Type": "application/json",
"Content-Length": "84",
"Date": "Tue, 16 Oct 2018 20:46:39 GMT"
}
}
"error_description": "Missing form parameter: grant_type"
I have defined grant_type: {"grant_type": "password", ... }
I also tried setting headers and ssl_verify=false ... without success
Hi,
I noticed I'm unable to add this library to my project via pipenv due to 'incompatible versions in the resolved dependencies' pipenv error.
This happens because some library vendors sticks to strict versions in their requirements.txt file like this:
requests==2.20.0
requests-oauthlib==1.0.0
Therefore if one library needs requests==2.20.0
while another library needs requests==2.12.4
then pipenv would be unable to satisfy those conditions.
Could we have a more relaxed versions specification, like the next example?
requests>=2.20.0
The same goes for other libraries within requirements.txt.
Thanks.
Hello,
I am trying to write a test step as follows:
Object $.request.body.data.attributes.participants required=["phone_number","name","email"]
I have also tried:
Object $.data.attributes.participants required=[“phone_number”,”name”,”email”]
The body data from Output is:
{
"request": {
"body": {
"data": {
"attributes": {
"participants": [
{
"phone_number": "5554447777",
"name": "QA Tester",
"email": "[email protected]"
}
],
"name": "Manual Test Room"
},
"type": "room"
}
},
....
I cannot understand why it is not finding the JSON path. The error is:
JSONPath query '$.request.body.data.attributes.participants' did not match anything.
This doesn't seem to be correct, as the path is clearly present. Can you take a look and let me know if I am missing something, or if this is a bug?
I'm working against a server with a self-signed certificate in a DEV environment. How do I keep the test from failing for this reason? An additional example with this would be good. Also one specifying headers.
GET to https://hidden.com/pathto SSL certificate verify failed:
HTTPSConnectionPool(host='hidden.com', port=443): Max retries exceeded with url: /pathto (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:726)'),))
The Output Schema
keyword does not work as documented.
Expected usage:
Output Schema response body
Result: No keyword with name 'Output Schema' found
The next one works - is not what is in documentation, though.
Output response body
Output schema response
Output schema response body
Result:
response body as JSON is:
"Hello World"
.
schema response as JSON is:
{
"body": {
"type": "string"
}
}
.
schema response body as JSON is:
{
"type": "string"
}
Hi,
My api post use Parameters
to send data, but post
keyword not have the argument, so I need to add all the params to the endpoint.
When I tried to install RESTinstance library with Python 3.6.5 - received below error message
Error Message:
Command ""c:\program files\python36\python.exe" -u -c "import setuptools, tokeni
ze;file='C:\Users\KKUPPU1\AppData\Local\Temp\pip-install-h6orvrho\Py1\AppData\Local\Temp\pip-record-ozn4knjk\install-record.txt --
YAML\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replac
e('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --recor
d C:\Users\KKUPPU
single-version-externally-managed --compile" failed with error code 1 in C:\User
s\KKUPPU~1\AppData\Local\Temp\pip-install-h6orvrho\PyYAML\
Are there plans to distribute a release version of this package? Since only pre-release versions are available, I am currently forced to allow pre-release installs in our Pipfile which causes some issues.
The underlying request library supports the use of sessions.
Do you think it would be feasible to provide a session parameter to the library?
eg: if i modify the spec file content , but api respone the correct fromat ,
the spec content only use in output instance file before request and respone josn node ,
but they not corresponding!!!
In the following robot tests, ${A} is correct, But ${B} occurs an error.
`*** Settings ***
Library REST https://jsonplaceholder.typicode.com
*** Test Cases ***
JSONPath query condition
${resp}= GET /users?_limit=4
Hi, I'm testing this extension on my REST API where, as REST, supports many representations for the same resource, for POST and GET.
I was testing with other formats than JSON for POST and it seems the library is not processing them correctly.
Is this library JSON only?
For content type - application/x-www-form-urlencoded, it always says "Missing grant_type parameter value"
Do we have any way to post "application/x-www-form-urlencoded" content types.
{"Content-Type": "application/x-www-form-urlencoded}
grant_type=password&username=test%40test.com&password=test%40018&scope=openid&tenantDomain=test.com
Output:
{
"error_description": "Missing grant_type parameter value",
"error": "invalid_request"
}
Please suggest
I am unable to set a specific port number in the URL without getting an error. I'm not very familiar with the new library, and this might not be the correct way of calling it either. Please advise on what I should do, or if this is a feature you'd like to support. Thanks!
Error below, example url
InvalidURL: Failed to parse: "example.com:8000" schema={ "exampled": false }
Library REST url="example.com:8000" schema={ "exampled": false }
*** Test Cases ***
Test Endpoint
GET /fakeusers
Hi, I dig into to the documentation and source code and I don't see any option to do basic authentication like this:
http://docs.python-requests.org/en/master/user/authentication/#basic-authentication
Thanks!
P.S: At the present time I put the credentials in the Library REST import like this:
Library REST http://${USER}:{PASS}@${URL}:${PORT}
This is not an issue, but more a question
When we use the Set Headers
Keyword, should we set them as a Dictionary? Please let me know
Hi,
Does REST support POST with Content-Type/x-www-form-urlencoded and encoded data?
*** Settings ***
Library REST https://jsonplaceholder.typicode.com
*** Test Cases ***
JSONPath query from object
GET /users/1
${lng}= Set Variable ${o_lng[0]}
I was trying to store the result from the String
keyword in a variable for further usage before I realized that it returns a list. I think it's not a real issue but it's not obvious that it returns a list without looking at the code of the keyword's implementation. Just want to share my experience in case somebody runs into it, too - and for my future me in case I run into it again 🤣
REST.Post /something ${body}
Integer response status 200
String response body idToken
${token}= String response body idToken
Log To Console ${token}
# console output
.['eyJhbGciOiJSUzI1NiIsImt ... ']
${token}
contains some characters which I did not expected to be there: [' ... ']
Now that I know that String
returns a list here is how the above should be done right
@{token}= String response body idToken
Log To Console @{token}
Log To Console @{token}[0]
Store the result in a list variable @{token}
and access the value at index 0 --> @{token}[0]
then I get what I actually wanted: eyJhbGciOiJSUzI1NiIsImt...
- the token as a string.
Cheers
Hi,
Is it possible to add Get Field Value
keyword to library?
Sometimes I need to exact some filed value from the previous request to test the current request.
Thanks!
Hi,
Getting "SchemaGenerationError: Could not find matching type for object: 1549286611000L" for most of my GET and POST call. Observed when JSON response is large. Also, same call executed successfully via POSTMAN and REST-ASSURED.
System details :
OS : Windows 10
robotframework==3.1.1
Pygments==2.2.0
wxPython= 2.8 (32 bit)
robotframework-ride==1.5.2.1
Python =2.7
I saw same issue has closed without much details #37. So appreciate your help on this.
hello, can you add example testcases for working with responses? i have a problem when i want to work with body response. thank you. i really appreciate your work.
Hello I am not sure if I am running into an issue or If my understanding is incorrect about the Expect Response keyword.
I am trying to do a simple up check on a service. For example, if I do a GET on http://helloworld.com/up
I would get an JSON like this {"version":"v1.0","status":"OK"}
I have this JSON schema that should validate this response
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"version": {
"type": "string"
},
"status": {
"type": "string"
}
},
"required": [
"status",
"version"
]
}
What I had tried to do is to use Expect Response keyword in Test Setup to set the schema above. And then use GET http://helloworld.com/up. But I keep getting and KeyError:"$schema".
Again, I am not sure if this is the right place to ask but I had been looking at this for a couple days and I really bugs me. Thank you.
{
"seconds": 0.085585,
"status": 200,
"body": {
"count": 6,
"entries": [
{
"Category": "Books",
"Description": "Bhagavad Gita text",
"Auth": "OAuth",
"API": "Bhagavad Gita",
"Link": "https://bhagavadgita.io/api",
"HTTPS": true,
"Cors": "yes"
},
{
"Category": "Books",
"Description": "Books published in the Netherlands and Flanders (about 2.5 million), book covers and related data",
"Auth": "",
"API": "BookNomads",
"Link": "https://www.booknomads.com/dev",
"HTTPS": true,
"Cors": "unknown"
},
{
"Category": "Books",
"Description": "Books",
"Auth": "apiKey",
"API": "Goodreads",
"Link": "https://www.goodreads.com/api",
"HTTPS": true,
"Cors": "unknown"
},
{
"Category": "Books",
"Description": "Books",
"Auth": "OAuth",
"API": "Google Books",
"Link": "https://developers.google.com/books/",
"HTTPS": true,
"Cors": "unknown"
},
{
"Category": "Books",
"Description": "Books, book covers and related data",
"Auth": "",
"API": "Open Library",
"Link": "https://openlibrary.org/developers/api",
"HTTPS": true,
"Cors": "unknown"
},]
}
}
I want to fetch data e.g. below Robot script
String response body entries[0] API Bhagavad Gita
Is there some reason that RC1 doesn't have anymore 'Expect Spec' keyword?
TL;DR the POST keyword eventually calls request.request using json= parameter for the body. Yet for XML the body is not in JSON format.
Detailed explanation of what I think is root cause along with sample code can be found here
Robot file to recreate issue:
*** Settings ***
Library REST
*** Variables ***
${SERVER_URL} https://www.w3schools.com/xml/tempconvert.asmx
*** Test Cases ***
Send XML Body test
Send SOAP via POST <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><FahrenheitToCelsius xmlns="https://www.w3schools.com/xml/"><Fahrenheit>100</Fahrenheit></FahrenheitToCelsius></soap:Body></soap:Envelope>
*** Keywords ***
Send SOAP via POST
[Arguments] ${body}
SET HEADERS {"SOAPAction": "https://www.w3schools.com/xml/FahrenheitToCelsius","Content-Type": "text/xml","Cache-Control": "no-cache"}
${resp}= POST ${SERVER_URL} data=${body}
Log ${resp} repr=true
Python code to prove endpoint works with Sample POST:
import requests
url = "https://www.w3schools.com/xml/tempconvert.asmx"
payload = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><FahrenheitToCelsius xmlns="https://www.w3schools.com/xml/"><Fahrenheit>100</Fahrenheit></FahrenheitToCelsius></soap:Body></soap:Envelope>'
headers = {
'SOAPAction': "\"https://www.w3schools.com/xml/FahrenheitToCelsius\"",
'Content-Type': "text/xml",
'Cache-Control': "no-cache",
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
i test your e.g ,but error ::
1.FAIL : No keyword with name 'DELETE' found;
2.how to import "Resource resources/mounterest.robot"
3.what is that mean ? "Library REST mounterest:${api_port}/" what is mounterest????
4.how to relate the swagger file?
thank you !
Note that the GenSON Python API has changed since 0.2.3.
Hi,
My problem is on my request server is using Kerberos authentication.
I tried to do | | Set Headers | { "Authorization" : "Negotiate"} |
Was trying to do something similar like what was successfully run using curl curl --negotiate -u : -X GET "url"
Searched around the documentation and didn't find any solution/documentation regarding this item
By using curl --negotiate -u : verbose,
I can see:
curl send request and return response is 401, www-authenticate: negotiate
curl send request with "Authorization" : "Negotiate {$kerberostoken}" and return response 200, with body result
Am I right in thinking the ssl certificate verification is disabled by default?
In keywords.py
if not request['sslVerify']: disable_warnings()
I was attempting to log in to a SUT with a self signed cert and the RESTinstance library using the following:
REST.Post ${api_login} { "username": "${temp_username}", "password": "${temp_password}" }
But am seeing the following error:
SSLError: HTTPSConnectionPool(host='192.168.n.n', port=443): Max retries exceeded with url: /login (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)'),))
Clear Expectations was removed, what is the replacement? This broke a lot of our tests.
Hi
I've a third party so called API poorly made to say the least. Would you be kind enought to provide an example about how to do multipart post ? I generated this python request snippet using my REST client (Insomnia), but I can't transcript it properly to robot / RESTinstance.
import requests
url = "http://192.168.60.10/api/index.php"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\nadmin"
headers = {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Thanks & regards,
I have a test suite where I have example
*** Settings ***
Test Setup Expect spec API_spec.json
*** Test Cases ***
example case 1
GET api_query_to_path
example case 2
GET api_query_to_path
Clear Expectations
GET query_that_path_doesn't_found from_spec
example case 3
Expect Spec spec={} replace=true
GET query_that_path_doesn't_found from_spec
Case 1 and 3 PASS
Case 2 gives FAIL
u'request':
- 'path':
- 'No paths found for path_that_doesn't_exist'
Question?
Should 'Clear Expectations'
to do same as 'Expect Spec spec={} replace=true'
does ?
Thanks for offering the nice Docker image.
I have been searching ... what does the extra parameter mean?
Whatever I try, I get 'data source not found'. Please help.
For example, I try this:
docker run -v ...jenkins-functionaltest-controllers/functional-testing-controllers/results:/opt/robotframework/reports -v .../jenkins-functionaltest-controllers/functional-testing-controllers/tests:/opt/robotframework/tests --network=myrestnetwork -e ROBOT_OPTIONS=--nostatusrc asyrjasalo/restinstance ControllersTest.robot
[ ERROR ] Parsing 'ControllersTest.robot' failed: Data source does not exist.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.