API POST /api/v1.0/account/users/ acting like I did GET

Status
Not open for further replies.

James Sefton

Cadet
Joined
Dec 19, 2014
Messages
1
Hi,

FreeNAS version 9.2.1.7

I have just started trying to learn how to use the API but I seem to be struggling to create a new user.

I first tried GET http://myhostname/api/v1.0/account/users with content-type set to application/json (I know thats not required for the GET) and basic authentication values set for the root account. This worked as expected and returned a list of users in JSON.

I then changed the GET to POST and included the following: (also tried variations of from the various examples I found)

{
"bsdusr_uid": 1017,
"bsdusr_username": "apitest",
"bsdusr_mode": "755",
"bsdusr_creategroup": true,
"bsdusr_password": "PlinkPlonk!232",
"bsdusr_shell": "/usr/sbin/nologin",
"bsdusr_full_name": "API Test",
"bsdusr_email": "foo@mydomain"
}

(foo@mydomain was a real email address)

From the documentation I expected this to return just the new user resource.
However, what is actually happening for me is that the user does not get created and it returns a full list of users, as though I had just done a GET. The response code was HTTP 200.

While scratching my head and assuming I had missed something silly, I also tried POST http://myhostname/api/v1.0/account/users/ (added trailing slash)
This returned just the word "GET" in the response body and HTTP 405. (Method Not Allowed)

As a sanity check, I then did GET http://myhostname/api/v1.0/account/users/ to see if I got the same message, but it returned a full list of users as expected.


I am using a chrome extension called POSTMAN to generate the request. I have used it for a lot of reST testing in the past and not had any issues with it.

I wanted to try and verify from the server side that the received request type was indeed POST but I have no idea where to find the http log. If anyone can point me to it that would be great.

Also, is there a known issue with this API call in this version of FreeNAS? In an ideal world my first port of call would be to upgrade straight to the newly released 9.3 but unfortunately this is not going to be possible in this case for at least a few months. (The server I need to make this work with was only recently installed and I cannot get away with downtime for an upgrade just now. 9.2.1.8 was the latest available at the time but 9.2.1.7 was installed due to a domain controller bug that was present in 9.2.1.8)

If anyone has any suggestions about where I might be going wrong then it would be very much appreciated.
 
D

dlavigne

Guest
This is probably a scripting error. If you create a bug report at bugs.freenas.org, make sure it includes your script and post the issue number here.
 
Status
Not open for further replies.
Top