Discussion:
[ovirt-users] issue creating disk with rest api using json format
Pascal D
2021-05-26 02:27:27 UTC
Permalink
I am unable to create disk using JSON however the same query in XML works great. In Json I get the following message back:
{
"detail": "For correct usage, see: https://ov1.butterflyit.com/ovirt-engine/apidoc#services/disks/methods/add",
"reason": "Request syntactically incorrect."
}

Both use POST /ovirt-engine/api/disks and the content-type is either application/json or application/xml

Here is the request in JSON:

{
"id": "866770c3-acf9-4f67-b72c-05ed241908e4",
"name": "mydisk",
"description": "test disk",
"bootable": false,
"shareable": true,
"provisioned_size": 10240000000,
"interface": "virtio",
"format": "cow",
"storage_domains": {
"storage_domain": {
"name": "VMS"
}
}
}

And here it is in XML

<disk id="866770c3-acf9-4f67-b72c-05ed241908e4">
<bootable>false</bootable>
<name>mydisk</name>
<description>test Drive</description>
<interface>virtio</interface>
<provisioned_size>10240000000</provisioned_size>
<format>cow</format>
<storage_domains>
<storage_domain>
<name>VMS</name>
</storage_domain>
</storage_domains>
</disk>
_______________________________________________
Users mailing list -- ***@ovirt.org
To unsubscribe send an email to users-***@ovirt.org
Privacy Statement: https://www.ovirt.org/privacy-policy.html
oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/
List Archives: https://lists.ovirt.org/archives/list/***@ovirt.or
Vojtech Juranek
2021-05-26 08:18:50 UTC
Permalink
Post by Pascal D
I am unable to create disk using JSON however the same query in XML works
{
Post by Pascal D
https://ov1.butterflyit.com/ovirt-engine/apidoc#services/disks/methods/add"
,
"reason": "Request syntactically incorrect."
Post by Pascal D
}
Both use POST /ovirt-engine/api/disks and the content-type is either
application/json or application/xml
{
"id": "866770c3-acf9-4f67-b72c-05ed241908e4",
"name": "mydisk",
"description": "test disk",
"bootable": false,
"shareable": true,
"provisioned_size": 10240000000,
"interface": "virtio",
"format": "cow",
"storage_domains": {
"storage_domain": {
"name": "VMS"
}
}
}
I didn't try, but I guess you need

{
disk = {
"id": "....",
...
}
}
Post by Pascal D
And here it is in XML
<disk id="866770c3-acf9-4f67-b72c-05ed241908e4">
<bootable>false</bootable>
<name>mydisk</name>
<description>test Drive</description>
<interface>virtio</interface>
<provisioned_size>10240000000</provisioned_size>
<format>cow</format>
<storage_domains>
<storage_domain>
<name>VMS</name>
</storage_domain>
</storage_domains>
</disk>
_______________________________________________
Privacy Statement: https://www.ovirt.org/privacy-policy.html
BW5PMNTCMB2PTIF6FT2/
Pascal D
2021-05-26 20:10:25 UTC
Permalink
I tried all sort of ways and none work in json. However I have no problem creating a VM using json or other entities. It seems to me it could be a bug and this is why I am reporting in. I am using 4.3 by the way.
_______________________________________________
Users mailing list -- ***@ovirt.org
To unsubscribe send an email to users-***@ovirt.org
Privacy Statement: https://www.ovirt.org/privacy-policy.html
oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/
List Archives: https://lists.ovirt.org/archives/list/***@ovirt.org/mess
Loading...