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

[Bug][SDK] Cannot setup webhook if org_id is not sent. #5857

Closed
2 tasks done
Dzeranov opened this issue Mar 15, 2023 · 3 comments
Closed
2 tasks done

[Bug][SDK] Cannot setup webhook if org_id is not sent. #5857

Dzeranov opened this issue Mar 15, 2023 · 3 comments
Assignees
Labels
bug Something isn't working sdk/cli

Comments

@Dzeranov
Copy link

Dzeranov commented Mar 15, 2023

My actions before raising this issue

Steps to Reproduce (for bugs)

Follow this example: https://opencv.github.io/cvat/docs/api_sdk/sdk/reference/apis/webhooks-api/#create
but without setting org_id field.

Expected Behaviour

No errors.

Current Behaviour

Invalid type for variable 'organization'. Required value type is int and passed type was NoneType at ['received_data']['organization']

Possible Solution

https://opencv.github.io/cvat/docs/api_sdk/sdk/reference/apis/webhooks-api/#create
https://opencv.github.io/cvat/docs/api_sdk/sdk/reference/models/webhook-read/
Despite the fact that org_id and organization fields are optional (and possible types are int and none_type) SDK is throwing error described above. Probably, the problem is with the API schema.

Your Environment

  • Git hash commit: 2c4676a
  • Docker version docker version: 20.10.22
  • Operating System and version: MacOS
@zhiltsov-max zhiltsov-max added bug Something isn't working sdk/cli labels Mar 16, 2023
@sizov-kirill sizov-kirill mentioned this issue Mar 23, 2023
7 tasks
@sizov-kirill sizov-kirill linked a pull request Mar 23, 2023 that will close this issue
7 tasks
@sizov-kirill
Copy link
Contributor

sizov-kirill commented Mar 23, 2023

Hi @Dzeranov, it seems that it's a problem in our documentation, we will fix it. But you can create webhook without specifying org_id with the following script

from cvat_sdk.api_client import Configuration, ApiClient, exceptions
from cvat_sdk.api_client.model.webhook_read import WebhookRead
from cvat_sdk.api_client.model.webhook_write_request import WebhookWriteRequest
from pprint import pprint

configuration = Configuration(
    host = "<your_host>",
    username = '<username>',
    password = '<password>',
)

with ApiClient(configuration) as api_client:
    webhook_write_request = WebhookWriteRequest(
        target_url="http://examples.com",
        description="description_example",
        type="project",
        content_type="application/json",
        secret="secret_example",
        is_active=True,
        enable_ssl=True,
        project_id=1,
        events=[
            "create:comment",
        ],
    )

    try:
        (data, response) = api_client.webhooks_api.create(webhook_write_request)
        pprint(data)
    except exceptions.ApiException as e:
        print("Exception when calling WebhooksApi.webhooks_create: %s\n" % e)

@sizov-kirill sizov-kirill removed a link to a pull request Mar 23, 2023
7 tasks
@sizov-kirill
Copy link
Contributor

Same problem as described in #5871

@sizov-kirill
Copy link
Contributor

Documentation problem has been resolved in #5903.
Valid example is here (it works without org_id)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sdk/cli
Projects
None yet
Development

No branches or pull requests

3 participants