Reputation: 115
I am new to Web API and the tutorial I was watching uses Fiddler to sniff and send request.
My question is how to use the post, put and delete methods without using fiddler and where are these usually used in the when creating in software development? Fiddler allows you to compose a request body how about the browser though?
I don't seem to understand why you are only able to use these on a sniffing tool. I understand that I am most probably speaking out of ignorance.
Upvotes: 0
Views: 1396
Reputation: 12351
If you simply want to create requests using some tool, then you can use tools like Fiddler, Postman, curl, etc. - as you have stated, Fiddler can also be used to monitor as well as create requests.
If you want to go beyond that,
See previous/other answers if you want to build/create requests client-side (Javascript
/ XMLHttpRequest
)
Hth.
Upvotes: 1
Reputation: 2337
(This answer is not specific to ASP.NET)
To avoid any confusion, I'm assuming you understand this much about RESTful webservices:
POST
.GET
.PUT
.DELETE
.As you noticed, only the GET
and POST
methods can be used in plain web forms. AJAX, however, supports using any HTTP method. Therefore, to use the PUT
and DELETE
methods, send your data to the server using JavaScript methods such as XMLHttpRequest, the newer Fetch API or a convenient wrapper like jQuery's $.ajax. (There are many tutorials for whichever you pick.) For example, if you have a form of updated values, replace your input
button with a button
element that has a JavaScript click event handler. The same principle applies to a delete link, swap the href
for a click event handler that makes an AJAX request to your server.
Upvotes: 1