How to send get request to a web API using CURL?

856 Views Asked by At

I have a Web API and it works fine when I send get requests to it using Postman. For example, the API can handle this request:

http://localhost:5000/api/test/?id=23

When I try the same exact thing with curl ($ curl http://localhost:5000/api/test/?id=23), I get this error:

curl: (3) URL using bad/illegal format or missing URL

What is wrong here?

1

There are 1 best solutions below

3
On

Probably your app supports only POST requests? curl http://localhost:5000/api/test/?id=23 will send GET request.

Try

curl -X POST http://localhost:5000/api/test/?id=23

If that does not work, the reason is probably in request headers, cookies, or (unlikely) user-agent handling in the API.