API: Create new Virtual Server (curl)

Hello, everyone,

i have the following problem, I’m trying to create a new VM via the API with the followed cURL command.
However, i get the message “{” hypervisor “: [” This field is required. “],” Type “: [” This field is required. “]}”

*curl -X POST https://api.example.de/api/virtual-servers/ -H ‘Authorization: Token XXXXXXXXXXXXX’ -H ‘Content-Type: application/json’ -d ‘{“hostname”:“test”, “hypervisor”:{“url”:“http://api.example.de/api/data-center-assets/3/”}, “status”: “in use”}’

In addition, I tried to specify the url/ui_url with [, ] and {, } as a sub-section for the hypervisior information, without success.

Can someone help me with this little difficulty?

I found the problem myself.
It is not necessary to specify the hypervisitor in the form of the URL, only the ID of the system. because django works with primarykeys.

-d ‘{“hostname”:“testie”, “hypervisor”:“1”, “type”:“1”, “status”: “in use”}’

1 Like

Exactly, as you described !