Connect to SSID and execute POST request

Is it possible to have a WiFi switch? I have a device with IP: 192.168.4.1 (Know SSID and password ). I need to have a switch that will automatically connect to SSID: name1 + password, and then execute the POST request. Once I am done wifi needs to be disconnected.

My HA connected via LAN, so onboard WIFi not used and I taught that I can use it for this option.
My Device Can’t be connected to HA it’s an access point and there no configaration, I need to connect there and I can see Web interface, I have checked already and POST commands can be executed once I am connected