This question discusses how to change the colour of a frame in beamer. You must add a setting outside the frame using {...}. This solution doesn't work for the table of contents. MWE below:

\documentclass{beamer}
\usetheme{default}

\AtBeginSection[]{
% with this one both are yellow
\setbeamercolor{background canvas}{bg=yellow}
\begin{frame}
% with this one both are white
%\setbeamercolor{background canvas}{bg=yellow}
\vfill
\tableofcontents[currentsection]
\vfill
\end{frame}
}

\begin{document}

\section{This should be yellow}

\begin{frame}

This should be white

\end{frame}

\end{document}


How can I achieve what is needed? This doesn't help either.

One solution I found is adding the table of content slide manually, using:

{
\setbeamercolor{background canvas}{bg=yellow}
\frame{\tableofcontents[currentsection]}
}


But if I have a many sections, is there a way to automate the above to all ToC frames?

Your original code will work if you add an extra pair of {}:

\documentclass{beamer}
\AtBeginSection{
{
\setbeamercolor{background canvas}{bg=yellow}
\begin{frame}
\vfill
\tableofcontents[currentsection]
\vfill
\end{frame}
}
}

\begin{document}

\section{This should be yellow}

\begin{frame}
This should be white
\end{frame}

\end{document}