403 error when accessing API

Can someone tell me how to get API access from an external web service? All I’m trying to do is flip on a switch, but I am getting a 403 ”AccessDenied, You are not authorized to perform the requested operation.” message.

This is what I’ve done, but I’m not sure if I’m missing something:

HTTP Headers contain:
Content-Type: application-json
Authorization: Basic {my_base_64_encoded username:password}

HTTP Body contains:
{command: on}

However, I get the 403. I can perform other API calls, and they work OK.

Can developers use an API via web service like this to control their things?

@snoopbuild - We’re still working to finish up the documentation and tutorials for how to expose web service endpoints from SmartApps. The draft documentation is available here:

but there are still a couple of sections missing. The main things that are missing are the discovery of your endpoints once the SmartApp is installed:

HTTP Header:
Authorization: Bearer [your OAuth2 token]

HTTP GET: https://graph.api.smartthings.com/api/smartapps/endpoints

Which should return something that looks like:

200 OK
	"oauthClient": {
  	"clientId": "myclient",
  	"authorizedGrantTypes": "authorization_code"
	"url": "/api/smartapps/installations/8a2aa0cd3df1a718013df1ca2e3f000c"

And making calls to your SmartApp:

Authorization: Bearer [your OAuth2 token]

HTTP GET: http://graph.api.smartthings.com/api/smartapps/installations/8a2aa0cd3df1a718013df1ca2e3f000c/switches

Will return a list of switches, and

Content-Type:  application/json
Authorization:  Bearer [your OAuth2 token]

PUT /api/smartapps/installations/8a2aa0cd3df1a718013df1ca2e3f000c/switches/8a818a9b39c0de7f0139c0dff1290073

Request body:
{“command”: “on”}

Will send the on command to a specific switch. I hope that’s helpful, and we should have the documentation completed and tutorials posted soon.

Hello Dan,

I followed the unfinished doc mentioned above by snoopbuild, mapped some api functions into my app. I successfully got an access token, retrieved my endpoint url but when I try to retrieve my switches list trough my endpoint url I’m getting an

HTTP/1.1 500 Internal Server Error.

Any help would be greatly appreciated.


OK after further research I found out that there was a problem in my web service app.