Skip to content

st2 POST API with content type= "application/x-www-form-urlencoded" not working #5512

@sravs-dev

Description

@sravs-dev

SUMMARY

Provide a quick summary of your bug report.

STACKSTORM VERSION

3.5

OS, environment, install method

Post what OS you are running this on, along with any other relevant information/

Running on Mac OS, installed using Docker. Issue is related to the rest api handling, nothing to do with host environment.

Steps to reproduce the problem

Make a post api to /sso/callback with a payload body of type "application/x-www-form-urlencoded"

Expected Results

What did you expect to happen when running the steps above?
st2 api should be able to parse the payload body into string and process it

Actual Results

What happened? What output did you get?

API failed to load bytes input in the body to a dictionary, hence returned 500 with the following stacktrace.
Fix needed: Bytes input should be converted to string before processing.

2021-12-20 18:04:00,275 139680124778496 DEBUG router [-] Missing x-api-model definition for st2auth.controllers.v1.sso:idp_callback_controller.post, using generic Body model. 2021-12-20 18:04:00,275 139680124778496 ERROR error_handling [-] API call failed: __init__() keywords must be strings Traceback (most recent call last): File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/middleware/error_handling.py", line 49, in __call__ return self.app(environ, start_response) File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/router.py", line 735, in as_wsgi resp = self(req) File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/router.py", line 560, in __call__ instance = self._get_model_instance(model_cls=model, data=data) File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/router.py", line 750, in _get_model_instance raise e File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/router.py", line 740, in _get_model_instance instance = model_cls(**data) TypeError: __init__() keywords must be strings (_exception_class='TypeError',_exception_message='__init__() keywords must be strings',_exception_data={}) 2021-12-20 18:04:00,275 139680124778496 DEBUG router [-] Match path: /sso/callback 2021-12-20 18:04:00,276 139680124778496 INFO logging [-] 548d58ec-1be5-4d43-8d51-a9926b21a6af - 500 39 3.427ms (method='POST',path='/sso/callback',remote_addr='172.21.0.1',status=500,runtime=3.427,content_length=39,request_id='548d58ec-1be5-4d43-8d51-a9926b21a6af')

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions