镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

No module named 'msgraph_beta.generated.models.submission_category' #690

Description

@megadodo100

Describe the bug

When following this article:
https://learn.microsoft.com/en-us/graph/api/security-emailthreatsubmission-post-emailthreats?view=graph-rest-beta&tabs=python

I receive an import error for:
from msgraph_beta.generated.models.submission_category import SubmissionCategory

The error:
No module named 'msgraph_beta.generated.models.submission_category'

Using version msgraph_beta_sdk-1.14.0

Expected behavior

the module to load

How to reproduce

run the following in python:
from msgraph_beta.generated.models.submission_category import SubmissionCategory

SDK Version

1.14.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

Ubuntu 22.04.5 LTS, x64

### Other information

_No response_

Activity

  1. megadodo100 commented on Dec 20, 2024

    @megadodo100
    Author

    still failing with msgraph_beta_sdk-1.15.0

  2. Ndiritu commented on Feb 4, 2025

    @Ndiritu
    Contributor

    megadodo100 thank you for reporting this. This appears to be a bug in our examples.
    The correct import path is: from msgraph_beta.generated.models.security.submission_category import SubmissionCategory (+ .security)

  3. megadodo100 commented on Feb 5, 2025

    @megadodo100
    Author

    Thanks Ndiritu, that has resolved that issues but I now get the following when submitting file content

    ---> 48 result = await graph_client.security.threat_submission.email_threats.post(request_body)
    49 print(result)
    50 else:
    51 print("Error obtaining token")

    /usr/local/lib/python3.10/dist-packages/msgraph_beta/generated/security/threat_submission/email_threats/email_threats_request_builder.py in ?(self, body, request_configuration)
    77 Find more info here: https://learn.microsoft.com/graph/api/security-emailthreatsubmission-post-emailthreats?view=graph-rest-beta
    78 """
    79 if body is None:
    80 raise TypeError("body cannot be null.")
    ---> 81 request_info = self.to_post_request_information(
    82 body, request_configuration
    83 )
    84 from ....models.o_data_errors.o_data_error import ODataError

    /usr/local/lib/python3.10/dist-packages/msgraph_beta/generated/security/threat_submission/email_threats/email_threats_request_builder.py in ?(self, body, request_configuration)
    114 raise TypeError("body cannot be null.")
    115 request_info = RequestInformation(Method.POST, self.url_template, self.path_parameters)
    116 request_info.configure(request_configuration)
    117 request_info.headers.try_add("Accept", "application/json")
    --> 118 request_info.set_content_from_parsable(self.request_adapter, "application/json", body)
    119 return request_info

    /usr/local/lib/python3.10/dist-packages/kiota_abstractions/request_information.py in ?(self, request_adapter, content_type, values)

    /usr/local/lib/python3.10/dist-packages/kiota_serialization_json/json_serialization_writer.py in ?(self, key, value, *additional_values_to_merge)
    305 if key:
    306 self.writer[key] = base64_string
    307 else:
    308 self.value = base64_string

    /usr/local/lib/python3.10/dist-packages/kiota_serialization_json/json_serialization_writer.py in ?(self, temp_writer, value)
    506 Args:
    507 key (Optional[str]): The key to be used for the written value. May be null.
    508 value (Any): The value to be written.
    509 """
    --> 510 value_type = type(value)
    511 if value is None:
    512 self.write_null_value(key)
    513 elif isinstance(value, Parsable):

    /usr/local/lib/python3.10/dist-packages/msgraph_beta/generated/models/security/email_content_threat_submission.py in ?(self, writer)
    50 Returns: None
    51 """
    52 if writer is None:
    53 raise TypeError("writer cannot be null.")
    ---> 54 super().serialize(writer)
    55 writer.write_str_value("fileContent", self.file_content)

    /usr/local/lib/python3.10/dist-packages/msgraph_beta/generated/models/security/email_threat_submission.py in ?(self, writer)

    /usr/local/lib/python3.10/dist-packages/msgraph_beta/generated/models/security/threat_submission.py in ?(self, writer)

    /usr/local/lib/python3.10/dist-packages/msgraph_beta/generated/models/entity.py in ?(self, writer)
    15561 from .organizational_branding import OrganizationalBranding
    15562 from .organizational_branding_localization import OrganizationalBrandingLocalization
    15563 from .organizational_branding_properties import OrganizationalBrandingProperties
    15564 from .organization_settings import OrganizationSettings

    15565 from .org_contact import OrgContact
    15566 from .outlook_category import OutlookCategory
    15567 from .outlook_item import OutlookItem
    15568 from .outlook_task import OutlookTask

    ModuleNotFoundError: No module named 'msgraph_beta.generated.models.organizational_branding_theme'

  4. megadodo100 commented on Feb 5, 2025

    @megadodo100
    Author

    Here is a snippet of the code used to submit:

    scopes = ['ThreatSubmission.ReadWrite.All']
    graph_client = GraphServiceClient(result, scopes)
    
    request_body = EmailContentThreatSubmission(
        odata_type = "#microsoft.graph.security.emailContentThreatSubmission",
        category = SubmissionCategory.Phishing,
        recipient_email_address = "the.recipient@email.address",
        file_content = base64.b64encode(raw_email.encode('utf-8')),
    )
    
    result = await graph_client.security.threat_submission.email_threats.post(request_body)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:documentationFocused on documentation of the producttype:bugA broken experience

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions