SmartThings Community

Why do I have the same location twice when getting endpoints for my Smart App

oauth

(Nicolas Guillaume) #1

Hello,

I’ve been working on a Smart App for a little while and I was adding support for a second location when I discovered something odd. When calling https://graph.api.smartthings.com/api/smartapps/endpoints the list that is returned contains the same location twice. I find this pretty confusing, what’s the logic behind it?

I’ve replaced all tokens with matching strings. In the sample bellow LOCATION_ONE is present twice with two different installations (INSTALL_ONE and INSTALL_TWO).

[
	{
		"oauthClient"=>{"clientId"=>"MYCLIENTID"},
		"location"=>{"id"=>"LOCATION_ONE_ID", "name"=>"LOCATION_ONE_NAME"},
		"uri"=>"https://graph-na04-useast2.api.smartthings.com:443/api/smartapps/installations/INTALL_ONE",
		"base_url"=>"https://graph-na04-useast2.api.smartthings.com:443",
		"url"=>"/api/smartapps/installations/INTALL_ONE"
	},{
		"oauthClient"=>{"clientId"=>"MYCLIENTID"},
		"location"=>{"id"=>"LOCATION_ONE_ID", "name"=>"LOCATION_ONE_NAME"},
		"uri"=>"https://graph-na04-useast2.api.smartthings.com:443/api/smartapps/installations/INTALL_TWO",
		"base_url"=>"https://graph-na04-useast2.api.smartthings.com:443",
		"url"=>"/api/smartapps/installations/INTALL_TWO"
	},{
		"oauthClient"=>{"clientId"=>"MYCLIENTID"},
		"location"=>{"id"=>"LOCATION_TWO_ID", "name"=>"LOCATION_TWO_NAME"},
		"uri"=>"https://graph-na04-useast2.api.smartthings.com:443/api/smartapps/installations/INSTAL_THREE",
		"base_url"=>"https://graph-na04-useast2.api.smartthings.com:443",
		"url"=>"/api/smartapps/installations/INSTAL_THREE"
	}
]

Does that mean that I can use either one of the installations to use that location? If that’s that case, wouldn’t the logical representation in JSON be to have LOCATION: {INSTALL, INSTALL} instead of [{LOCATION, INSTALL},{LOCATION, INSTALL}]