API for getting channel invites?

The CLI must use some secret API for getting channel invite details, as I don’t see it anywhere in the RESTful API documentation.

Is there an endpoint for getting the invite info (specifically the accept URL) for a specific channel?

I believe there is a /invites endpoint. I haven’t really looked into it though. It is slightly unusual in that it isn’t being picked up from the Core SDK as most endpoint information is, though it may simply be the case that they are still refactoring and it is last on the list to be done.

Have you tried turning on debugging in the CLI? That is often quite helpful at revealing API calls.

1 Like

That’s a great suggestion, thank you!

However there does seem to be something unique with this particular command. This is what CLI debug log shows:

making axios request: {"url":"https://api.smartthings.com/invites","method":"get","headers":{"Content-Type":"application/json;charset=utf-8","Accept":"application/json","User-Agent":"@smartthings/cli/1.0.0-beta.9 linux-arm node-v16.15.1","Accept-Language":"en-US","Authorization":"Bearer 58fbc7f4-xxxx-xxxx-xxxx-xxxxxxxxxxxx"},"params":{"resource":"st1:developer::channel/e6e29aeb-2793-4ebf-b8f6-e37b69e32c61"}}

which confirms what you said - that there IS an invites endpoint. But trying to reproduce this using Postman with this URL:

https://api.smartthings.com/v1/invites?resource=st1:developer::channel/e6e29aeb-2793-4ebf-b8f6-e37b69e32c61

gives me a 406 error with this return message:

Resource representation is only available with these types:
application/json

Haven’t figured it out yet, but still trying variations.

Did you include the header for Accept: application/json? That’s usually what an HTTP 406 is pointing to.

Yes, I made sure of that. No luck.

This value logged by the CLI referred to as “params”:

{“resource”:“st1:developer::channel/e6e29aeb-2793-4ebf-b8f6-e37b69e32c61”}

I tried providing that in the body with a Content-Type header of application/json, but that yields this error:

Request is missing required query parameter ‘resource’

So it definitely seems to want it as a standard URL parameter. Just not sure of the exact syntax it’s looking for for that value of “st1:developer::channel/e6e29aeb-2793-4ebf-b8f6-e37b69e32c61”

I’ve had a play. I normally use Accept: application/vnd.smartthings+json;v=1 as, despite what the API reference claims, the more interesting version numbers don’t work when used inline in the URL. That gives the 406 but changing to the basic Accept: application/json as specified in the debug works fine.

So take the debug line literally and don’t include the /v1 in the URL.

2 Likes

OMG I’m an idiot! Sometimes it just takes a second pair of eyes… THANK YOU!