Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request POST JSON data is not handled as expected #68

Open
petschki opened this issue Jun 2, 2022 · 2 comments
Open

request POST JSON data is not handled as expected #68

petschki opened this issue Jun 2, 2022 · 2 comments

Comments

@petschki
Copy link

petschki commented Jun 2, 2022

What I did:

I sent an XHR call to zope like this:

const resp = await fetch("@@backend", {
    headers: {
        "Content-Type": "application/json",
    },
    method: "POST",
    body: JSON.stringify({
        id: "some_id",
        _authenticator: "some_authenticator",
    }),
});

What I expect to happen:

If I want to read the request in @@backend browser view I expect:

self.request.form = {
    "id": "some_id",
    "_authenticator": "some_authenticator",
}

What actually happened:

You have to extract the body data manually via:

form_data = json.loads(self.request["BODY"])

What version of Python and Zope/Addons I am using:

python: 3.9
Zope: master
Plone: 6.0-dev

@petschki petschki changed the title request POST JSON data is not recognized request POST JSON data is not handled as expected Jun 2, 2022
@d-maurer
Copy link

d-maurer commented Jun 2, 2022 via email

@mgedmin
Copy link
Member

mgedmin commented Sep 11, 2022

-1 for reusing request.form for this.

+1 for introducing a new request.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants