I am new to the forums, but familiar with python / restful apis. I am confused as to why i am getting an error of 'Field was not expected'.
Here is the error log i am getting.
From the documentation I found RestApi Docs endpoint of sharing/nfs. This to me would be the method to create a share.
The code i am using is as follows.
This i am not worried about Created By {utility['user']['username']}. The utility i am using does variable swap at the time of the script running. and you can see from the debug section - it is printing out the payload with no issues.
I would assume "path" is required so confused as to why it is saying Field was not expected.
The true nas system i am using is as follows:
OS Version:
TrueNAS-13.0-U5.3
Any help would be greatly appreciated to figure out how to troubleshoot or to correct said issue.
Here is the error log i am getting.
Code:
2023-09-06 13:15:31,212:64::main:INFO:Dataset does not exist 2023-09-06 13:15:31,212:65::main:INFO:Creating Dataset 2023-09-06 13:15:31,421:68::main:INFO:Dataset created 2023-09-06 13:15:31,421:53::create_nfs_share:DEBUG:{'path': '/mnt/VMware/test01', 'comment': 'Created By custom1', 'enabled': True} {'path': [{'message': 'Field was not expected', 'errno': 22}]}
From the documentation I found RestApi Docs endpoint of sharing/nfs. This to me would be the method to create a share.
The code i am using is as follows.
Code:
def create_nfs_share(headers, truenas_baseurl, new_dataset): payload1 = { "path": f"/mnt/{new_dataset}", "comment": f"Created By {utility['user']['username']}", "mapall_user": "root", "security": ["SYS"], "enabled": True } logger.debug(payload1) headers['Content-Type'] = 'application/json' result = requests.post(f"{truenas_baseurl}api/v2.0/sharing/nfs", headers=headers, verify=False, data=json.dumps(payload1)).json() print(result)
This i am not worried about Created By {utility['user']['username']}. The utility i am using does variable swap at the time of the script running. and you can see from the debug section - it is printing out the payload with no issues.
I would assume "path" is required so confused as to why it is saying Field was not expected.
The true nas system i am using is as follows:
OS Version:
TrueNAS-13.0-U5.3
Any help would be greatly appreciated to figure out how to troubleshoot or to correct said issue.