Hi,
I'm having trouble creating a dataset with the REST API. I'm using the python requests module. The server responds with 301 moved permanently, and then, without my intention, a get request is made by client. This is confusing because the python function returns the status from the get call (which succeeds) rather than the post call. If I make another request with the uri given by the location field of the response, I get 400 bad request. Can anyone help me out with this?
Note that the uri that I specify the first post request is identical to the uri in the location field of the response except for a trailing forward slash in the response.
The requests (in python) and responses (from tcpdump) are as follows:
r = requests.post('http://freenasServer/api/v1.0/storage/volume/myvolume/datasets', auth=('user', 'password'), headers={'Content-Type': 'application/json', data={'name': 'apiTest'})
HTTP/1.1 301 MOVED PERMANENTLY
Server: nginx/1.6.2
Date: Fri, 07 Aug 2015 00:09:46 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Content-Language: en-us
Location: http://freenasServer/api/v1.0/storage/volume/myvolume/datasets/
Vary: Accept-Language
r = requests.post('http://freenasServer/api/v1.0/storage/volume/myvolume/datasets/', auth=('user', 'password'), headers={'Content-Type': 'application/json', data={'name': 'apiTest'})
HTTP/1.1 400 BAD REQUEST
Server: nginx/1.6.2
Date: Fri, 07 Aug 2015 00:56:43 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Content-Language: en
Vary: Accept-Language, Cookie
I'm having trouble creating a dataset with the REST API. I'm using the python requests module. The server responds with 301 moved permanently, and then, without my intention, a get request is made by client. This is confusing because the python function returns the status from the get call (which succeeds) rather than the post call. If I make another request with the uri given by the location field of the response, I get 400 bad request. Can anyone help me out with this?
Note that the uri that I specify the first post request is identical to the uri in the location field of the response except for a trailing forward slash in the response.
The requests (in python) and responses (from tcpdump) are as follows:
r = requests.post('http://freenasServer/api/v1.0/storage/volume/myvolume/datasets', auth=('user', 'password'), headers={'Content-Type': 'application/json', data={'name': 'apiTest'})
HTTP/1.1 301 MOVED PERMANENTLY
Server: nginx/1.6.2
Date: Fri, 07 Aug 2015 00:09:46 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Content-Language: en-us
Location: http://freenasServer/api/v1.0/storage/volume/myvolume/datasets/
Vary: Accept-Language
r = requests.post('http://freenasServer/api/v1.0/storage/volume/myvolume/datasets/', auth=('user', 'password'), headers={'Content-Type': 'application/json', data={'name': 'apiTest'})
HTTP/1.1 400 BAD REQUEST
Server: nginx/1.6.2
Date: Fri, 07 Aug 2015 00:56:43 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Content-Language: en
Vary: Accept-Language, Cookie