Please see Melachim 1 8:16. Why doesn’t Shlomo quote what G-d said to David accurately (Shmuel 2 chapter 7). Is one allowed to paraphrase G-d in this way?
It isn’t clear to me what quote you are referring to, but please see Rashi and Ralbag Melachim 8-15, that the meaning of the verse is “And he (Shlomo) said, “Blessed is H-shem the G-d of Yisroel that He said to my father David (that He would give him a son that would build the Bais Hamikdash), and he fulfilled it, as the following”. According to their understanding, Shlomo wasn’t quoting anything, rather he was thanking H-shem for fulfilling his promise that He would build the Bais Hamikdash.