Home > database >  How do I call my Django REST API endpoint with CURL?
How do I call my Django REST API endpoint with CURL?

Time:02-15

I want to call my Django REST Framework API using cURL, but it doesn't do anything.

My URL is like "https://MYURL/api/seedevents?secret=SECRET". In postman this works and returns a 201 Created HTTP response. If I call using CURL for example "curl -XGET 'https://MYURL/api/seedevents?secret=SECRET', then it doesn't do anything at all. I can see the request come in in the logs, but it just doesn't do anything.

Please can someone advise me what I can do?

CodePudding user response:

I guess it's probably missing some headers.

A helpful tip is to extract the curl command from Postman, on the right side you will find a code symbol as the below screenshot, that will make the same request in different form, choose cURL and use the command (make sure to use data instead of data-raw in case you have a payload)

enter image description here

Also add -vvv after curl to debug the curl

  • Related