简体   繁体   中英

How to pass extra parameters in HTTP DELETE request?

I am writing a REST API, which supports POST/GET/DELETE method for the same url.

For the DELETE method, the API needs extra parameters (details of the deletion). But the library I am using doesn't support request body for DELETE method, how can I do it?

If I put the parameter in URL like:

DELETE /API/Resource/id/parameter

Then I break the RESTyness. Or I need to use another method POST/PUT, which is not RESTy, either.

Why is POST / PUT not RESTy? Take a look at the twitter REST API : You can destroy a status by POSTing to /statuses/id/destroy . That request does accept parameters. You could do something similar to this:

POST /API/Resource/id/destroy

I think that is RESTy enough.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM