microsoftgraph / msgraph-sdk-python

MIT License
360 stars 49 forks source link

Python: Cancel Appointment issues/errors #659

Closed moonbox3 closed 3 months ago

moonbox3 commented 5 months ago

Is your feature request related to a problem? Please describe.

There are several issues I am finding with the cancel appointment graph call:

I'm trying to follow the cancel appointment Python example, and the import used is incorrect. Per the following code it looks like the import should be something like from msgraph.generated.users.item.events.item.cancel.cancel_post_request_body import CancelPostRequestBody.

Next, the docs example shows:

request_body = CancelPostRequestBody(
    cancellation_message = "Your appointment has been successfully cancelled. Please call us again.",
)

yet the CancelPostRequestBody constructor takes a comment instead of a cancellation_message.

Again following the example, I must be forming the request body incorrectly because I am getting a 500 back (shouldn't it be a 400)? I noticed on previous calls, like to create an appointment, when I had a malformed request, it returned a 500. In any case, I see the following when trying to cancel an appointment:

msgraph.generated.models.o_data_errors.o_data_error.ODataError: 
        APIError
        Code: 500
        message: None
        error: MainError(additional_data={}, code='UnknownError', details=None, inner_error=InnerError(additional_data={}, client_request_id='4a6277e9-75a1-414b-b69a-d8c27b85369c', date=DateTime(2024, 4, 11, 16, 37, 40, tzinfo=Timezone('UTC')), odata_type=None, request_id='aa2c88c9-66dd-4b8c-af38-7f726d40d8f8'), message='', target=None)

when using the following code:

# First cancel the reservation
request_body = CancelPostRequestBody(
    comment="Your appointment has been successfully cancelled. Please call us again.",
)

await self.graph_client.solutions.booking_businesses.by_booking_business_id(
    self.booking_business_id
).appointments.by_booking_appointment_id(reservation_id).cancel.post(request_body)

Based on the CancelPostRequestBody fields, I've tried sending with either just the comment field filled out or all fields configured (backing_store, additional_data, and comment) yet that fails.

Describe the solution you'd like I'd like for the cancel appointment API to be documented properly so I can understand how to form the request and cancel an appointment. Thank you for your help.

shemogumbe commented 4 months ago

Hello, Thanks for your continues use of the SDK and for raising this. If I get you right, do you mean the CancelPostRequestBody does not expect a key cancelation_token , does that throw a keyError for you?

moonbox3 commented 4 months ago

Hi @shemogumbe. That is not correct. Can you please re-read my original issue/bug?

microsoft-github-policy-service[bot] commented 3 months ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.