asyrjasalo / RESTinstance

Robot Framework library for RESTful JSON APIs
https://pypi.org/project/RESTinstance
GNU Lesser General Public License v3.0
205 stars 84 forks source link

ScannerError: mapping values are not allowed here #57

Closed Tset-Noitamotua closed 2 years ago

Tset-Noitamotua commented 5 years ago

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 :laughing:

Can "the scanner" be turned off by some option switch?

asimell commented 3 years ago

Hi @Tset-Noitamotua,

Currently the library supports only JSON format. You can also see from the stack trace that your Post is trying to call

File "/home/robot/src/REST/keywords.py", line 993, in input
    return self._input_json_from_file(what)

which obviously fails, since your input is XML. Whether we want to support XML in the future is an other question entirely, but for now only JSON is supported.

asimell commented 2 years ago

We decided to not add XML support for now. This library is for JSON APIs. If there is more interest to use XML we can consider this again. Closing issue for now.