On 06/23/2015 02:49 PM, Scott Miller wrote: > I am unable to POST with json to the REST api. Every attempt is returned with: > > { > "message": "Request syntactically incorrect. See the description > below for the correct usage:", > > From what I can see the syntax should be ok however I am unable to > locate any json examples for the ovirt REST api on github, or in any > ovirt docs. > > Can you help me? >
Should be something like this (using curl): ---8<--- #!/bin/sh -ex url="https://engine.example.com/ovirt-engine/api" user="admin@internal" password="..." curl \ --insecure \ --user "${user}:${password}" \ --request POST \ --header "Content-Type: application/json" \ --header "Accept: application/json" \ --data ' { "name": "scott_test", "cluster": { "name": "LabRDU" }, "template": { "name": "CentOS-6.6-RDU" } } ' \ "${url}/vms" --->8--- Note that in the JSON document you don't need a wrapping "vm" element, and that the names of the cluster and the template are inner elements. When in doubt you can obtain examples from the RESTAPI itself. For example, if you want to see how a VM is represented using JSON go to a URL like this in your browser: https://.../ovirt-engine/api/vms/the-id-of-the-vm?accept=application/json > Details: > > RHEVM 3.5.3.1-1.4.el6ev > > Testing app: > Postman > > > Example requests with only basic needed items to create a VM, both > fail with above syntax error: > > > POST /api/vms HTTP/1.1 > Host: xxxxxxxxxxxxxxxx > Authorization: Basic xxxxxxxxxxxxxxx > Content-Type: application/json > Accept: application/json > Cache-Control: no-cache > Postman-Token: 8816bbe9-998e-02b6-1873-f4292657868e > > > { > "vm": { > "name": "scott_test", > "cluster.name": "LabRDU", > "template.name": "CentOS-6.6-RDU" > } > } > > > > POST /api/vms HTTP/1.1 > Host: xxxxxxxxxxxxxxxxx > Authorization: Basic xxxxxxxxxxxxxxxx > Content-Type: application/json > Accept: application/json > Cache-Control: no-cache > Postman-Token: 8816bbe9-998e-02b6-1873-f4292657868e > > > { > "vm.name": "scott_test", > "vm.cluster.name": "LabRDU", > "vm.template.name": "CentOS-6.6-RDU" > } > _______________________________________________ > Users mailing list > Users@ovirt.org > http://lists.ovirt.org/mailman/listinfo/users > -- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L. _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users