Unable to set/change DNS from REST API
Description
Problem/Justification
Impact
Attachments
- 07 Jul 2023, 02:01 PM
- 07 Jul 2023, 02:01 PM
is duplicated by
Activity
Kris Moore July 7, 2023 at 2:01 PM
Guessing that sending along the “state” is what is confusing it. Suggest you experiment the built-in CLI to prototype and see what params are valid:
Running the command with the ‘--’ option will bring up the editor so you can see all the valid params:
Dionisis Deligiannopoulos July 7, 2023 at 9:01 AM
The goal is to change the nameserver2
from empty to 1.0.0.1
payload = {
"id": 1,
"hostname": "truenas",
"domain": "local",
"ipv4gateway": "172.16.0.1",
"ipv6gateway": "fe80::daec:e5ff:fe78:7877",
"nameserver1": "1.1.1.1",
"nameserver2": "1.0.0.1",
"nameserver3": "",
"httpproxy": "",
"netwait_enabled": false,
"netwait_ip": [],
"hosts": "",
"domains": [],
"service_announcement": {
"mdns": true,
"wsd": true,
"netbios": true
},
"activity": {
"type": "DENY",
"activities": []
},
"hostname_local": "truenas",
"state": {
"ipv4gateway": "172.16.0.1",
"ipv6gateway": "fe80::5862:27ff:fe5b:e9df",
"nameserver1": "1.1.1.1",
"nameserver2": "1.0.0.1",
"nameserver3": ""
}
}
url='http://my_ip/api/v2.0/network/configuration'
headers = {'Content-Type': 'application/json'}
requests.put(
url, verify=False, headers=headers, data=payload,
timeout=self.config['timeout'],
auth=(user , password)
)
Returns
'500 Internal Server Error\n\nServer got itself in trouble'
Kris Moore July 6, 2023 at 2:47 PM
@Dionisis Deligiannopoulos - We’re going to need more specific examples of how you called the API, since this works for our usage. Can you provide the full usage of how you formatted the request?
Automation for Jira July 6, 2023 at 2:40 PM
Thank you for submitting this TrueNAS Bug Report! So that we can quickly investigate your issue, please attach a Debug file and any other information related to this issue through our secure and private upload service below. Debug files can be generated in the UI by navigating to System -> Advanced -> Save Debug.
https://ixsystems.atlassian.net/servicedesk/customer/portal/15/group/37/create/153
When trying to set or change a nameserver using the REST API, an error is returned:
'500 Internal Server Error\n\nServer got itself in trouble'