#Can’t create item in postman using x-www-urlencoded or form-data

10 messages · Page 1 of 1 (latest)

fallen quest
#

here is the collection

#

So it happens when I use x-www-urlencoded or form-data. If I select raw everything works fine. But I need to test app using form-data I guess it has to work as expected but doesn't for some reason&

fallen quest
#

Still need help

#

Can’t create item using postman and x-www-urlencoded or form-data

fallen quest
#

Someone please

#

Can’t create item in postman using x-www-urlencoded or form-data

flint mica
#

I'm a bit green on this, but I think problem arises from the fact that those rest routes are generated and have some kind of default config.

Maaaaaaybe one of the solutions could be to create your own endpoints. For example:

import { CollectionConfig } from "payload/types"
import payload from "payload"

const Orders: CollectionConfig = {
    slug: 'orders',
    endpoints: [
        {
            // url: /api/orders/some-route
            path: '/some-route',
            method: 'post',
            handler: async (req, res, next) => {
                // data is in req: req.body, req.params, ...
            },
        },
    ],
    fields: [
        // ...
    ],
}

export default Orders

But also, documentation says something about overriding headers of those default routes: https://payloadcms.com/docs/rest-api/overview#method-override-for-get-requests but these examples don't really help and they don't really talk about overriding POST requests...

fallen quest