0
votes

I'm trying to use spanner emulator and I followed the instructions reported here: https://cloud.google.com/spanner/docs/emulator

to set it up. I can use gcloud shell commands to create instance, database, tables, etc. and all works correctly.

But I am not able to use the Rest API directly to access the emulator, even though the google documentation reports it is possible not only to use google client libs to access the emulator, but also the rest api.

The first problem is that it is not clear if I have to use either the base URL https://spanner.googleapis.com/ or http://localhost:9020/

When I try with

http://localhost:9020/v1/parent=projects/local-project/instanceConfigs

I always returns and "Not found" message, which means the the Rest API ws are responding, but through gcloud commands I can manage such instance and project!

What am I wrong with?!

2

2 Answers

0
votes

According to the official documentation :

Using the Cloud Spanner Emulator

"The Cloud SDK provides a local, in-memory emulator, which you can use to develop and test your applications for free without creating a GCP Project or a billing account."

Therefore you should use the localhost (localhost:9020 for REST requests).

0
votes

You should use http://localhost:9020 to access the emulator if you want to manually access the REST API, so you were on the right track there.

The URL should however be http://localhost:9020/v1/projects/test-project/instanceConfigs to list all instance configurations on the emulator. Use http://localhost:9020/v1/projects/test-project/instances to list all instances.