Thibaut
Dabbler
- Joined
- Jun 21, 2014
- Messages
- 33
Hello,
I'm new to FreeNAS API usage and just starting to play around with it.
I'm willing to set up a web interface that would mainly let registered users manage iSCSI targets, extents and target to extents. I've successfully managed to have the volumes, targets, extents... listed using FreeNAS API using the following python code in my views.py file:
What I'm willing to do now is use the POST method to create new entries, but this doesn't seem to work. Here's what I get from the python shell:
Same goes for PUT requests...
What am I missing ?
Any help would be appreciated.
Thank you.
I'm new to FreeNAS API usage and just starting to play around with it.
I'm willing to set up a web interface that would mainly let registered users manage iSCSI targets, extents and target to extents. I've successfully managed to have the volumes, targets, extents... listed using FreeNAS API using the following python code in my views.py file:
Code:
from django.shortcuts import render def index(request): # FreeNAS API query import requests import json from django.http import HttpResponse api_url = 'http://123.123.123.123/api/v1.0/' login = ('root', '123456') vols = requests.get( api_url + 'storage/volume/', auth=login, params={'offset': 0, 'limit': 10000} ) targs = requests.get( api_url + 'services/iscsi/target/', auth=login, params={'offset': 0, 'limit': 10000} ) exts = requests.get( api_url + 'services/iscsi/extent/', auth=login, params={'offset': 0, 'limit': 10000} ) luns = requests.get( api_url + 'services/iscsi/targettoextent/', auth=login, params={'offset': 0, 'limit': 10000} ) vols_json = vols.json() targs_json = targs.json() exts_json = exts.json() luns_json = luns.json() ...
What I'm willing to do now is use the POST method to create new entries, but this doesn't seem to work. Here's what I get from the python shell:
Code:
>>> import requests >>> import json >>> api_url = 'http://123.123.123.123/api/v1.0/' >>> login = ('root', '123456') >>> r = requests.post(api_url + 'services/iscsi/targettoextent/', auth=login, params={"iscsi_target": 2, "iscsi_extent": 2}) >>> r.text u'{"error_message": "Sorry, this request could not be processed. Please try again later."}'
Same goes for PUT requests...
What am I missing ?
Any help would be appreciated.
Thank you.