I couldn't see much wrong with that code, but I did change it to make it more readable.
MsgBox filepath
ActiveWorkbook.Queries.Add Name:="IMportJSON", Formula:= _
"let" & vbNewLine & _
" Source = Json.Document(File.Contents(""" & filepath & """))," & vbNewLine & _
" toTable = Record.ToTable(Source)" & vbNewLine & _
"in" & vbNewLine & _
" toTable"
But when I tried this with a Json doc I quickly knocked up it failed as the import created a list of 3 records, and it couldn't convert the list to a Record. I got around that with
totable = = Record.ToTable(Source{0})
but of course that only converted the first record.
I suggest you import that Json doc using Power Query and play around in there to get what you want, that will provide the query for you.