It works fine on my local machine, but when I use a VM I keeping getting an error;
Error: lexical error: invalid char in json text.
<html lang="en"
(right here) ------^
My first guess would be that, for some reason, accessing this page from the VM doesn't return a JSON but some generic html page. On the VM, try to download the content of that URL and see what's in it. I wouldn't be surprised if you got this:
Instagram decided that your VM's IP is suspicious and denied it access. (I got the screenshot when I tried from TOR).
If it's really the IP that's suspicious to Instagram, you need to try from a different IP, maybe by respawning the VM or via a VPN. I don't know what else I could suggest I'm afraid.
Instagram might have a key-ed API, in which case it might not look at your IP as long as you have a valid key. Not sure.