what type of cable should I use
All ports on the TP Link TL-SF1008D support Auto-MDIX, so you can use any straight-through or crossover 8P8C terminated (RJ45) Cat 5/5E/6 twisted-pair Ethernet cable.
if I am using the 2 pair cable (instead of 4) between the switch and the router I am able to connect to the internet but same is not true in case of 4 pair cat5 cable.
100Base-T only needs two pairs. Your 4-pair Cat5 cable is broken or incorrectly wired, test it with a suitable cable-tester.