$_PARAM does not work with DELETE method

Wappler Version : 3.6.0
Operating System : Windows 10
Server Model: Node
Database Type: MySQL
Hosting Type: Local

Expected behavior

What do you think should happen?

Passing the following URL with DELETE method should delete the record.


Actual behavior

What actually happens?

I get a 404 not found.

If I do the same but use a GET instead of DELETE, then the record is returned.

How to reproduce

  1. Setup a Server Connect/API with multiple conditions for each REQUEST_METHOD type (i.e. GET, DELETE, etc).

  2. Add a Database Delete action and a Database Query action under their respective Condition.

  3. Setup a Route with the ID as the route parameter.

  4. Perform a GET method to verify it returns a record.

  5. Perform a DELETE method on the same record.

The routes set using the UI in Wappler are only for GET, if you want to set a DELETE route you have to edit the routes.json directly, it is located in app/config/routes.json. Find the route you created in the JSON and add an extra property to it "method": "delete".

Perhaps we could change the default to accept all methods or add an option to the UI to allow you set the method for the route, which is probably preferred if you are creating a rest api.

@patrick am I able to add multiple methods? If so, how?

Adding delete worked, so it appears GET, POST, and DELETE are now working, but PATCH is not.

Also, if I add patch instead of delete, then I get this error.

"status": "500",

    "message": "Empty .update() call detected! Update data does not contain any values to update. This will result in a faulty query. Table: Contact. Columns: Account,FirstName,LastName,Company,isPinned,VIP,Email.",

    "stack": "Error: Empty .update() call detected! Update data does not contain any values to update. This will result in a faulty query. Table: Contact. Columns: Account,FirstName,LastName,Company,isPinned,VIP,Email.\n    at QueryCompiler_MySQL._prepUpdate (/opt/node_app/node_modules/knex/lib/query/compiler.js:819:13)\n    at QueryCompiler_MySQL.update (/opt/node_app/node_modules/knex/lib/dialects/mysql/query/compiler.js:59:26)\n    at QueryCompiler_MySQL.toSQL (/opt/node_app/node_modules/knex/lib/query/compiler.js:61:29)\n    at Builder.toSQL (/opt/node_app/node_modules/knex/lib/query/builder.js:97:44)\n    at /opt/node_app/node_modules/knex/lib/runner.js:31:36\n    at /opt/node_app/node_modules/knex/lib/runner.js:277:24\n    at processTicksAndRejections (internal/process/task_queues.js:97:5)\n    at async App.update (/opt/node_app/lib/modules/dbupdater.js:54:24)\n    at async App._exec (/opt/node_app/lib/core/app.js:425:30)\n    at async App._exec (/opt/node_app/lib/core/app.js:396:17)"

How do you pass data with the patch? Not sure if the body parser in express parses the body on anything else then post.

I’m attempting to pass json key:value pairs in the body. I realize this doesn’t follow RFC 5789 or RFC 6902, but it should suffice for sending what I need.

Try posting it as a valid json string in the body and content type application/json, then express middleware should parse it correctly.

It doesn’t work.

I also tried changing the logic and using POST, but it doesn’t work either.

@patrick, I figured it out – although, in order to get the update to work, I had to add a duplicate route for each – except the PATCH method still doesn’t work.

I can use POST to update, but I would prefer to use PATCH.

If you use the same action for all the methods you could just use all as method, that would catch all the different methods. We will make that the default for the next update instead of get.

1 Like

In the next update we will have a method choice per route. So you can specify that a special route will be available only for the DELETE method.

Then the route will be executed only when called with DELETE - and there is no need to do a request_method == ‘DELETE’ check in it.


Thanks @patrick and @george!

My preference would be to have the option to pick multiple methods for a route – not just one. Also there’s a lot of methods and not all may be valid, or desired, for a route specific route.

This has been improved in Wappler 3.6.1 - now there’s a method dropdown available.

1 Like

This topic was automatically closed after 45 hours. New replies are no longer allowed.