Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't create Hono connection via Connections HTTP API POST #1746

Open
calohmn opened this issue Sep 10, 2023 · 3 comments
Open

Can't create Hono connection via Connections HTTP API POST #1746

calohmn opened this issue Sep 10, 2023 · 3 comments

Comments

@calohmn
Copy link
Contributor

calohmn commented Sep 10, 2023

A Hono connection requires the connection ID to be set to the ID of the Hono tenant that this connection is to be used for.

But, when trying to create a Hono connection via the Connections HTTP API, along with specifying the connection ID in the request JSON, there is an error response:

{
  "status": 400,
  "error": "connectivity:id.notsettable",
  "message": "It is not allowed to provide an explicit ID for a connection.",
  "description": "Remove the ID from the connection as it will be generated."
}

Therefore it seems a Hono connection can't be created in the recommended way using the HTTP API. Instead, the piggyback commands API needs to be used.

@thjaeckle
Copy link
Member

This should be possible using the PUT method and specifying the ID in the path.

But yes, same should also be possible using POST and id in payload.
That validation is outdated.

@calohmn calohmn changed the title Can't create Hono connection via Connections HTTP API Can't create Hono connection via Connections HTTP API POST Sep 11, 2023
@thjaeckle
Copy link
Member

Update on this after looking into it: At least this is consistent for also creating things via POST and policies via POST.

So the current behaviour for all POST methods is:

  • an ID is automatically created by Ditto
  • if an ID is provided in the payload, a "Bad Request" is returned with the hint that setting the id for a newly created entity is not supported
    • the exception texts for creating policies and things are better as they mention the HTTP verb POST or e.g. mention: To provide your own Thing ID use a PUT request instead

One could now argue that we want to allow setting the entityId in the payload of the body - which would be ok for me. But I also don't have a strong need for that.

@calohmn
Copy link
Contributor Author

calohmn commented Sep 11, 2023

Ok. Then I think it would be good to add a note in the manage connections documentation about the possibility to use PUT /api/2/connections/my_id to create a connection (also adding the hint that the If-None-Match: * header can be used to ensure no update is done).
In the Hono-connection documentation page, this could be described as the way to create the connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants