Niels Erik
Dabbler
- Joined
- Aug 9, 2015
- Messages
- 18
Hi
I'm trying to unlock a volume via. the API, but it fails.
I can lock it again if i unlock it via. the GUI.
The unlock API is documented here, and I cant see what I'm doing wrong.
http://api.freenas.org/resources/storage.html#unlock
I suspect that something is wrong with the encoding of the passphrase, misspelling the passphrase tag does not change the reponse.
If i provide an invalid volume name, it reports not found.
If i provide invalid credentials it reports not authorized.
I use the following python code to unlock the volume.
Printout from the code:
Post captured with Wireshark:
Responce captured with Wireshark:
I'm trying to unlock a volume via. the API, but it fails.
I can lock it again if i unlock it via. the GUI.
The unlock API is documented here, and I cant see what I'm doing wrong.
http://api.freenas.org/resources/storage.html#unlock
I suspect that something is wrong with the encoding of the passphrase, misspelling the passphrase tag does not change the reponse.
If i provide an invalid volume name, it reports not found.
If i provide invalid credentials it reports not authorized.
I use the following python code to unlock the volume.
import requests
import json
Server ="somedomain.com"
User ="root"
Password ="secret"
vol_name ="BackupVolume"
VolumeUnlockReq = json.dumps({"passphrase": "anothersecret"})
Resurce ="/api/v1.0/storage/volume/"+vol_name+"/unlock/"
url = "http://"+Server+Resurce
ReqData ="Content-Type: application/json "+VolumeUnlockReq
print("URL :",url)
print("ReqData :",ReqData)
response=requests.post(url,data=ReqData,auth=(User, Password))
print("Status code:",response.status_code)
print("Reason :",response.reason)
if(response.text):
print("response :",json.loads(response.text))
Printout from the code:
URL : http://somedomain.com/api/v1.0/storage/volume/BackupVolume/unlock/
ReqData : Content-Type: application/json {"passphrase": "anothersecret"}
Status code: 400
Reason : Bad Request
response : {'error_message': 'Sorry, this request could not be processed. Please try again later.'}
Post captured with Wireshark:
POST /api/v1.0/storage/volume/BackupVolume/unlock/ HTTP/1.1
Host: somedomain.com
User-Agent: python-requests/2.19.1
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Length: 60
Authorization: Basic XXXXXXXXXXXXXXXXXXX=
Content-Type: application/json {"passphrase": "anothersecret"}
Responce captured with Wireshark:
HTTP/1.1 400 Bad Request
Server: nginx
Date: Wed, 27 Feb 2019 06:49:04 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Language, Cookie
Content-Language: en
58 {"error_message": "Sorry, this request could not be processed. Please try again later."} 0