It’s actually given you some Apps Script code (UrlFetchApp
is an Apps Script method), which is a flavour of JavaScript, which is definitely not Java. Java & JavaScript are two very different animals
Anyway, that won’t work as it is in a JavaScript column.
It would however be possible to craft some JavaScript that would work. Not something I’ve attempted to do yet (just one thing on a very long list of things I’d like to play with), but somebody else might have.