#RestAPI for license NLF installation
1 messages · Page 1 of 1 (latest)
curl -X POST -u "login:password" -H "Content-Type: application/json" -d "@licensefile.nlf" "https://<mgmt-ip>/api/cluster/licensing/licenses"
what is this -d @nlflicensefile.nlf ? im trying to do it via invoke-restapi
From the curl man page
-d, --data <data>
(HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses
the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded. Compare to -F, --form.
--data-raw is almost the same but does not have a special interpretation of the @ character. To post data purely binary, you should instead use the --data-
binary option. To URL-encode the value of a form field you may use --data-urlencode.
If any of these options is used more than once on the same command line, the data pieces specified will be merged together with a separating &-symbol. Thus,
using '-d name=daniel -d skill=lousy' would generate a post chunk that looks like 'name=daniel&skill=lousy'.
If you start the data with the letter @, the rest should be a file name to read the data from, or - if you want curl to read the data from stdin. Multiple
files can also be specified. Posting data from a file named from a file like that, carriage returns and newlines will be stripped out. If you don't want the @
character to have a special interpretation use --data-raw instead.
What do you mean by invoke-restapi?
because im reading the content of the file and post it as an json body to my POST call. but always got the error that unexpected character are in the body:
"error": {
"message": "Unexpected argument "HostID".",
"code": "262179",
"target": "HostID"
}
some if i copy the information of the nlf file and do it via the /docs/api page with the try function of this exact uri
same if i copy -- typo
also with -Infile i receive the same error that there is unexpected argument. so the information in the file is not correct.
i also created a netapp case for that. 2009695120
I checked how System Manager does it. The NLF is converted to a json-safe string and surrounded by this:
{ "keys": [ "NLF-CONTENT" ] }
yes im also that far. already wraped it in the keys array. but yes some how here is a problem i dont know if its the file or the body. because it ready the information from the NLF file but receiving the error:
"The value "succcess" is invalid for field "keys[0]"",
and success is the first key value pare from the NLF file.
You can't just throw the NLF in. Like I said you have to convert it to be a json-safe string.
The following works from a Linux console. Installation of the jq tool is required. It uses jq to create the needed json-safe string from the NLF and also the surrounding json structure.
JSONBODY=$(jq '{ "keys": [ tostring ] }' /path/to/NLF.txt) curl -X POST -u "user:password" -H "Content-Type: application/json" -d "$JSONBODY" "https://<mgmt-ip>/api/cluster/licensing/licenses"