Search code examples
curlodatadynamics-nav

Authenticating OData using Curl for Dynamics Nav


I'm trying to use Curl to pull some data from Microsoft Dynamics Nav.

I can easily access it through my browser at this url: http://kevans:(password)@192.168.0.30:8048/Sandbox/OData/ and it works perfectly fine.

In Curl, I tried this: curl --ntlm -u kevans "http://192.168.0.30:8048/Sandbox/OData/" -v, type in my password at the prompt, but it returns a 401 Unauthorized error.

Is there something that needs to be done to make it available to Curl?

Here's the output of Curl:

curl --ntlm -u kevans "http://192.168.0.30:8048/Sandbox/OData/" -v
Enter host password for user 'kevans':
* About to connect() to 192.168.0.30 port 8048 (#0)
*   Trying 192.168.0.30...
* Adding handle: conn: 0x525fe0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x525fe0) send_pipe: 1, recv_pipe: 0
* Connected to 192.168.0.30 (192.168.0.30) port 8048 (#0)
* Server auth using NTLM with user 'kevans'
> GET /Sandbox/OData/ HTTP/1.1
> Authorization: NTLM TlRMTVNTUAABAAAAt4II4gAAAAAAAAAAAAAAAAAAAAAGA4AlAAAADw==
> User-Agent: curl/7.33.0
> Host: 192.168.0.30:8048
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Content-Length: 0
* Server Microsoft-HTTPAPI/2.0 is not blacklisted
< Server: Microsoft-HTTPAPI/2.0
< WWW-Authenticate: Negotiate
< Date: Thu, 05 Feb 2015 20:25:26 GMT
<
* Connection #0 to host 192.168.0.30 left intact

Things I've tried:

  • using the --negotiate argument along with --ntlm
  • using --anyauth
  • using my domain -u MYDOMAIN\kevans
  • using -u MYDOMAIN\kevans:password and -u kevans:password

Solution

  • I updated Curl from 7.33 to 7.40 and it works fine now. I'm using the EXACT SAME COMMAND and it works without issue. The domain is completely optional and doesn't seem to affect it.