This is because you were trying the request from your browser address bar, in which case the browser automatically adds Accept: text/html
to the request headers⁽¹⁾.
Then, because the Places API has some web helper tool to play with available parameters, it returns html (the Web UI) because Accept: text/html
was found in the request headers.
The solution to add callback
is more a workaround, since it wraps the response with the value of the callback parameter.
Your initial request was actually valid. If you send it from your program or a REST client like Postman instead of from the browser, you actually get JSON by default, so there was nothing more to do. Of course, you can explicitly send the header Accept: application/json
to be on the safe side.
[1] Open the network panel of the browser developer tools to see what is sent.