15 March 2019

CURL on WINDOWS: double quotes and other issues

I had to insert metadata information to Cloudera Navigator, and the CURL command didn't work for me. Specifically, I was struggling with this piece of code:

$ curl http://localhost:7187/api/v2/entities/ \
-u : \ -X POST -H "Content-Type: application/json" \ -d '{ "sourceId":"4fbdadc6899638782fc8cb626176dc7b", "parentPath":"myDatabase/myTable", "originalName":"newColumn", "name":"awesomeColumn", "description":"This is going to be an awesome column.", "tags":["fav"], "properties":{"priority":"medium"} }'

This code is copied from here: Cloudera Navigator API - update an entity to add new business metadata.

 and since I'm such a sweet person, here's how it works on Windows:

curl http://localhost:7187/api/v2/entities/ ^ -u : ^ -X POST -H Content-Type: application/json ^ -d "{ \"sourceId\":\"4fbdadc6899638782fc8cb626176dc7b\", \"parentPath":"myDatabase/myTable\", \"originalName":"newColumn\", \"name":\"awesomeColumn\", \"description":\"\This is going to be an awesome column."\, \"tags\":[\"fav\"], \"properties\":{\"priority\":\"medium\"} }"


So what do we get out of this?

  1. The "\" to the end of line is changed to ^
  2. No single quotes; they are all removed
  3. The JSON text is surrounded with double quotes, not single quotes
  4. The double quotes inside the JSON files are escaped with a backslash. 


You're welcome.