REST API create_vm returns task URL that doesn't exist?
-
Hi everyone,
I'm currently creating VMs via the REST API endpoint:
POST /rest/v0/pools/${poolId}/actions/create_vm
Everything works great so far, but since I'm managing VMs externally via my own panel, I need the UUID of the newly created VM as part of the response.
Right now, my workaround is to cache all existing VMs beforehand, use a very unique name (including a timestamp) when creating the VM, and then scan all VMs afterward to find the new one by matching the name — from which I can extract the UUID. This works, but it's far from efficient, especially since I have to query every single VM individually to get the name_label.
However, I noticed that the API call returns something like this:
XOA success response: "/rest/v0/tasks/0mcmb9kba"
But as far as I can tell, there is no /rest/v0/tasks endpoint available in the REST API. So... why does create_vm return a reference to a resource that doesn't exist?
I was quite excited at first, thinking this would let me track the task and maybe get the VM UUID without extra API calls — but it seems like a dead end.
@devs – Is there any timeline on when this /tasks route will be available? And in the meantime, could you consider not returning references to non-existent endpoints? It's a bit misleading and made me waste some time debugging something that doesn't exist (yet?).
Thanks in advance!
-
Hi,
Let me ask the XO team via @lsouai-vates
-
@DevFlint the https://XOA_URL/rest/v0/tasks endpoint exists, but it's not yet documented through swagger
you should be able to add ?sync=true to the url to get the immediate result, but it can fail with a timeout if the creation takes too much time ( for example : migrating a big template )
-
Hello @DevFlint.
/rest/v0/tasks/:idexists. It's not yet documented in Swagger, but it does exist.FYI, "actions" endpoint are specific.
They can be executed asynchronously (which is what you're currently doing). In this case, a task is returned and needs to be monitored. Use/rest/v0/tasks/:idfor this.
You can also execute your action synchronously by usingsync=trueas a query parameter. In this case, the VM ID will be returned in response.This should normally be documented in Swagger. If it's not clear in the documentation, we can improve it

-
@MathieuRA I can’t find any documentation of /tasks/ in swagger, I am on the newest Version of XOA
-
This is normal, as the
tasksendpoints are in the old REST API (undocumented by Swagger).
We are gradually migrating to the new REST API to document all endpoints.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login