If an STM32 is in a low power mode such as shutdown mode, then programming it can be tricky. This video shows how I managed to program my STM32F103 using an STLINK V2 when the chip was in shutdown mode.
...
https://www.youtube.com/watch?v=LeNwufD18cQ