H
H
howgreat212020-01-30 13:25:20
RESTful API
howgreat21, 2020-01-30 13:25:20

POST request where to implement?

I'm trying to make a Simple RESTful service like this on a local server:
https://webdevkin.ru/posts/backend/restful-servis-...
There are requests
1. GET /goods - Get product information
2. POST /goods - Adding a new item
$method = $_SERVER['REQUEST_METHOD']; - with this line I catch the method that is used in the request.
If I serve localhost2/goods , then I have GET in $method, but if we want to add a product, then I need a POST method, but it also has an address of localhost2/goods and the service treats it as GET, I didn’t understand how POST is correct at all use

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Tallmange, 2020-01-30
@p00h

POST is not done by entering the address in the browser bar. Use wget, curl and other analogs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question