Community discussions

MikroTik App
 
user442
just joined
Topic Author
Posts: 3
Joined: Sat May 20, 2023 12:33 am

Start and stop containers via REST API?

Wed Nov 29, 2023 3:02 pm

Can anyone help? I've been trying to start and stop a container via the REST api but I can't figure out what to put in the POST request.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 4324
Joined: Sun May 01, 2016 7:12 pm
Location: California
Contact:

Re: Start and stop containers via REST API?

Wed Nov 29, 2023 5:54 pm

You can do a GET request to <routerurl>/rest/container first, that will get you the ".id" for your container. If the container never get deleted then .id never changes, so may be able to skip this step. The ".id" should have a star (*) and a number, like *33. This .id also should up in CLI via "/container/print show-ids"

With the .id of the container, you can then do a POST to <routerurl>/rest/container/start, with a JSON body like { "number": "*33" } — where "number" means the ".id" of the container.

FWIW , I created a schema for the REST API that's usable in stuff like Postman that helps figure some of these things out: viewtopic.php?t=199476
 
elico
Member Candidate
Member Candidate
Posts: 158
Joined: Mon Nov 07, 2016 3:23 am

Re: Start and stop containers via REST API?

Sat Dec 02, 2023 11:25 am

@user442 using what tools?
curl would be good?

Who is online

Users browsing this forum: No registered users and 2 guests