I have a .Net API exposed, running on an IIS Server. There is a Windows scheduled task that executes nightly. It runs a cURL request. When I copy that command and execute it in a cmd window, it returns a 401.
I try the same api call in Postman, and get a 200.
IIS logs show:
2020-06-04 02:59:55 W3SVC3 127.0.0.1 POST /api/tasks/checkstaledirectdebits - 443 - 127.0.0.1 PostmanRuntime/7.25.0 - - example.com 200 0 0 557
My cURL command is this:
-X POST https://example.Com/api/tasks/checkstaledirectdebits -H "Connection: keep-alive" -H "Content-Type: application/json" -H "X-API-Key: MyValidKey" -H "Accept: ." -H "Host: api.kikka.com.au" -H "cache-control: no-cache" -H "Content-Length: 0"
And IIS logs:
2020-06-04 02:58:37 W3SVC3 127.0.0.1 POST /api/tasks/checkstaledirectdebits - 443 - 127.0.0.1 curl/7.59.0 - - example.com 401 0 0 4640
Both the cUrl command, and the Postman instance are running on the server. The same one the API is running on. Am I missing something that Postman does, that I need to make cURL do?