Problem with adding folder to the side bar

This is not directly supported in Ubuntu desktop based on Gnome Shell. The dock hosts applications, not files.

To quickly access folders, you can use bookmark folders. You also could create a folder and populate it with symlinks to folders for quick access.

What you can do, though, is create a .desktop launcher for the folder in your .local/share/applications folder. Supply nautilus <folderpath>, or even better xdg-open <folderpath> on the Exec= line. Such launcher will appear in the Application overview, from where you could pin it as a favorite on the dock. By default, there is no way to create a .desktop file through the GUI, but you still could install menulibre or alacarte to do this.