truenas API v2.0 : howto update dataset using curl command ?

JCL

Dabbler
Joined
Nov 18, 2015
Messages
14
Hello there,

I had no issues to use freenas api v1.0 to create or update information on dataset. Now with truenas api v2.0, I can create dataset but I did not find a solution how to update it.

Exemple:
Here, I create a dataset of 1GB with name TEST01 on pool md72 using curl POST command. ( I use api key for authentification, mytruenas is an alias of my machine )


Code:
curl -X POST "http://mytruenas/api/v2.0/pool/dataset" -H "Authorization: Bearer $key"  -H  "accept: */*" -H  "Content-Type: application/json" -d "{\"name\":\"md72/TEST01\",\"quota\":1073741824}"


From the mytruenas GUI, I can see the newly created dataset TEST01

According to the documentation (http://mytruenas/api/docs),
there is the following PUT /pool/dataset/id/{id} which is suppose to "updates a dataset/zvol id", but I don't know how to use it, I have always errors.

I would like to modify this TEST01 dataset, using curl PUT command, for example to increase the quota size.
I tried different solutions (which was working with api v 1.0) but with no success fom api 2.0. All the following curl commands don't work :


Code:
curl -s -X PUT "http://mytruenas/api/v2.0/pool/dataset" -H "Authorization: Bearer $key"  -H  "accept: */*" -H  "Content-Type: application/json" -d "{\"name\":\"md72/TEST01\",\"quota\":2073741824}"
405: Method Not Allowed


Code:
curl -s -X PUT "http://mytruenas/api/v2.0/pool/dataset/md72/TEST01" -H "Authorization: Bearer $key"  -H  "accept: */*" -H  "Content-Type: application/json" -d "{\"quota\":2073741824}"
404: Not Found


Code:
curl -s -X PUT "http://mytruenas/api/v2.0/pool/dataset/id/md72/TEST01" -H "Authorization: Bearer $key"  -H  "accept: */*" -H  "Content-Type: application/json" -d "{\"quota\":2073741824}"
404: Not Found


Is anyone could explain me how to use curl command to update a dataset ?

Thanks in advance,
Jean-Charles
 

JCL

Dabbler
Joined
Nov 18, 2015
Messages
14
Hi,
I have found myself the answer. For some reason I don't know, when you add the dataset name at the end of the URL that you pass to curl command, "/" character must be replaced with "%2F" sequence of characters.

Now with the following command, I can update the dataset "md72/TEST01":

Code:
curl -s -X PUT "http://mytruenas/api/v2.0/pool/dataset/id/md72%2FTEST01" -H "Authorization: Bearer $key" -H "accept: */*" -H "Content-Type: application/json" -d "{\"quota\":2073741824}"


Jean-Charles
 
Last edited:
Top