Using WiFiClient: compilation error ' "server" not declared in scope '

In the working code you have a declaration of server:

const char* server = "api.thingspeak.com";

In the non-working code you do not, thus the error.

Although it seems counterintuitive, it's actually better to turn off verbose compilation output when posting errors/warnings to the forum (File > Preferences > Show verbose output during > compilation (uncheck) > OK). The information the verbose output provides is only needed very rarely and the extra characters can push you over the 9000 character limit. Attaching a txt file with the error message is fine when absolutely necessary but it may cause some people to not bother/be able to download and open the file so you have a lesser chance of getting help. If we do end up needing verbose output we can always ask for it. Now for upload errors I think it's always useful to have the verbose output since the non-verbose output doesn't give much helpful information.

brice3010:
As a bonus: why does the compiler often use libraries not stored in my standard Arduino Library folder but uses a folder in C:\Users\Myname\AppData\Local\Arduino15\packages.... ? Annoying because -as far as I know- I have no control over what is stored there..

The Arduino IDE tries to automatically figure out which is the best library to use when multiple libraries contain the filename you include . One of the primary things that determines which library gets include priority is architecture matching. The architecture of a library is defined in its library.properties file. The order is: exact match > wildcard match > mismatch. Another criterion is library folder name. If the library folder name matches the included filename that file gets priority. If both of those are equal then the library in the sketchbook folder gets include priority. The libraries at C:\Users\Myname\AppData\Local\Arduino15\packages.... are those bundled with the hardware package. They are written specifically for the the board you have currently selected in the Tools > Board menu.