diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 7832e81..b65f89d 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -25,6 +25,7 @@
 #include <utils/fw_utils.hpp>
 #include <utils/systemd_utils.hpp>
 
+#include <cstdint>
 #include <memory>
 #include <sstream>
 #include <variant>
@@ -1808,11 +1809,12 @@
                  const std::vector<std::string>& params) override
     {
         std::optional<nlohmann::json> oem;
+        std::optional<nlohmann::json> links;
         std::optional<std::string> datetime;
         std::shared_ptr<AsyncResp> response = std::make_shared<AsyncResp>(res);
 
         if (!json_util::readJson(req, response->res, "Oem", oem, "DateTime",
-                                 datetime))
+                                 datetime, "Links", links))
         {
             return;
         }
@@ -1843,6 +1845,29 @@
                 }
             }
         }
+        if (links)
+        {
+            std::optional<nlohmann::json> activeSoftwareImage;
+            if (!redfish::json_util::readJson(
+                    *links, res, "ActiveSoftwareImage", activeSoftwareImage))
+            {
+                return;
+            }
+            if (activeSoftwareImage)
+            {
+                std::optional<std::string> odataId;
+                if (!json_util::readJson(*activeSoftwareImage, res, "@odata.id",
+                                         odataId))
+                {
+                    return;
+                }
+
+                if (odataId)
+                {
+                    setActiveFirmwareImage(response, std::move(*odataId));
+                }
+            }
+        }
         if (datetime)
         {
             setDateTime(response, std::move(*datetime));
@@ -1884,6 +1909,116 @@
             "xyz.openbmc_project.State.BMC", "LastRebootTime");
     }
 
+    /**
+     * @brief Set the running firmware image
+     *
+     * @param[i,o] aResp - Async response object
+     * @param[i] runningFirmwareTarget - Image to make the running image
+     *
+     * @return void
+     */
+    void setActiveFirmwareImage(std::shared_ptr<AsyncResp> aResp,
+                                const std::string&& runningFirmwareTarget)
+    {
+        // Get the Id from /redfish/v1/UpdateService/FirmwareInventory/<Id>
+        std::string::size_type idPos = runningFirmwareTarget.rfind("/");
+        if (idPos == std::string::npos)
+        {
+            messages::propertyValueNotInList(aResp->res, runningFirmwareTarget,
+                                             "@odata.id");
+            BMCWEB_LOG_DEBUG << "Can't parse firmware ID!";
+            return;
+        }
+        idPos++;
+        if (idPos >= runningFirmwareTarget.size())
+        {
+            messages::propertyValueNotInList(aResp->res, runningFirmwareTarget,
+                                             "@odata.id");
+            BMCWEB_LOG_DEBUG << "Invalid firmware ID.";
+            return;
+        }
+        std::string firmwareId = runningFirmwareTarget.substr(idPos);
+
+        // Make sure the image is valid before setting priority
+        crow::connections::systemBus->async_method_call(
+            [aResp, firmwareId,
+             runningFirmwareTarget](const boost::system::error_code ec,
+                                    ManagedObjectType& subtree) {
+                if (ec)
+                {
+                    BMCWEB_LOG_DEBUG << "D-Bus response error getting objects.";
+                    messages::internalError(aResp->res);
+                    return;
+                }
+
+                if (subtree.size() == 0)
+                {
+                    BMCWEB_LOG_DEBUG << "Can't find image!";
+                    messages::internalError(aResp->res);
+                    return;
+                }
+
+                bool foundImage = false;
+                for (auto& object : subtree)
+                {
+                    const std::string& path =
+                        static_cast<const std::string&>(object.first);
+                    std::size_t idPos2 = path.rfind("/");
+
+                    if (idPos2 == std::string::npos)
+                    {
+                        continue;
+                    }
+
+                    idPos2++;
+                    if (idPos2 >= path.size())
+                    {
+                        continue;
+                    }
+
+                    if (path.substr(idPos2) == firmwareId)
+                    {
+                        foundImage = true;
+                        break;
+                    }
+                }
+
+                if (!foundImage)
+                {
+                    messages::propertyValueNotInList(
+                        aResp->res, runningFirmwareTarget, "@odata.id");
+                    BMCWEB_LOG_DEBUG << "Invalid firmware ID.";
+                    return;
+                }
+
+                BMCWEB_LOG_DEBUG << "Setting firmware version " + firmwareId +
+                                        " to priority 0.";
+
+                // Only support Immediate
+                // An addition could be a Redfish Setting like
+                // ActiveSoftwareImageApplyTime and support OnReset
+                crow::connections::systemBus->async_method_call(
+                    [aResp](const boost::system::error_code ec) {
+                        if (ec)
+                        {
+                            BMCWEB_LOG_DEBUG << "D-Bus response error setting.";
+                            messages::internalError(aResp->res);
+                            return;
+                        }
+                        doBMCGracefulRestart(aResp);
+                    },
+
+                    "xyz.openbmc_project.Software.BMC.Updater",
+                    "/xyz/openbmc_project/software/" + firmwareId,
+                    "org.freedesktop.DBus.Properties", "Set",
+                    "xyz.openbmc_project.Software.RedundancyPriority",
+                    "Priority", std::variant<uint8_t>(static_cast<uint8_t>(0)));
+            },
+            "xyz.openbmc_project.Software.BMC.Updater",
+            "/xyz/openbmc_project/software",
+            "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
+    }
+
     void setDateTime(std::shared_ptr<AsyncResp> aResp,
                      std::string datetime) const
     {
