0

I am trying to create and API which uses VERB PUT,GET,DELETE

I can use it in curl by this

curl -X DELETE http://localhost:8080/recipes/hi

But how can i use similarly in url

for eg

This works

http://localhost:8080/recipes/hi

But this is not working

http://localhost:8080/recipes/DELETE/foo

How to add verb DELETE in url?

2
  • 1
    Warning - please do not use obscenities in your posts. I've removed it for you. Note that other users may have flagged your post as "rude or abusive" leading to possible rep loss or suspension. Please read Be Nice: "Avoid vulgar terms and anything sexually suggestive"
    – DavidPostill
    Mar 23, 2016 at 10:38
  • Issues specific to programming and software development are off topic, see On-Topic. Try Stack Overflow but please first read How do I ask a good question?.
    – DavidPostill
    Mar 23, 2016 at 10:39

1 Answer 1

4

You don't.

The HTTP verbs (GET, POST, PUT, DELETE, HEAD, and OPTIONS) are applied to a URL. They are not elements of a URL.

You can see that in your cURL example: curl -X DELETE http://localhost:8080/recipes/hi

Here the HTTP verb is DELETE, while the URL is http://localhost:8080/recipes/hi. Verb and URL: two different things.

In general, when you enter a URL into a browser address bar, it will issue a GET request to that URL. Browsers will issue POST requests when submitting a form on a HTML page with a method="POST" attribute.

<form method="post" action="http://localhost:8080/submit">

If you fill in this form, the browser will submit a POST request to that URL.

Browsers will not, in the normal course of events, issue PUT, DELETE, HEAD, or OPTIONS requests. They can, but it will require scripting with javascript.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .