Conference Data is not being Generated in Google Calendar Ap
2024-04-17 13:45

try { final serviceAccountCredentialsFile = 'assets/fineappl-test-database-59bc63f88a9e.json'; // final serviceAccountCredentialsFile = 'assets/chalogekya-3104d-a83272eadffe.json'; final credentialsJson = await services.rootBundle.loadString(serviceAccountCredentialsFile);

final credentials = auth.ServiceAccountCredentials.fromJson(credentialsJson); final scopes = [calendar.CalendarApi.calendarScope]; final client = await auth.clientViaServiceAccount(credentials, scopes); final calendarApi = calendar.CalendarApi(client); final event = calendar.Event(); event.summary = "Meet Test"; event.start = calendar.EventDateTime(); event.start!.dateTime = DateTime.parse("2024-02-29T18:00:00"); event.start!.timeZone = "Asia/Kolkata"; event.end = calendar.EventDateTime(); event.end!.dateTime = DateTime.parse("2024-02-29T19:00:00"); event.end!.timeZone = "Asia/Kolkata"; event.conferenceData = calendar.ConferenceData( conferenceSolution: ConferenceSolution(key: ConferenceSolutionKey(type: 'hangoutsMeet',), ), // conferenceId: "dfg-udhv-pou", createRequest: calendar.CreateConferenceRequest( requestId: 'hfiufniu84y8315izf78hue', conferenceSolutionKey: calendar.ConferenceSolutionKey( type: 'hangoutsMeet', ), ), ); final createdEvent = await calendarApi.events.insert(event, '[email protected]',conferenceDataVersion: 1); print("hecjhnucjk ${createdEvent.hangoutLink}"); print("id ${createdEvent.id}"); print("conferenceData ${createdEvent.conferenceData?.createRequest?.status?.statusCode}"); print("status ${createdEvent.status}"); print("email ${createdEvent.creator?.email}"); return createdEvent; } catch (error, stackTrace) { print('Error creating event: $error'); print('Stack trace: $stackTrace'); rethrow; // Rethrow the error to propagate it }

I am trying to create an event in google calender using google calendar api with google meet link in that event. My event is being generated but the meet link or conference data is coming null. Guidance needed.




other answer :

It seems like youre trying to create a Google Calendar event with conference data using Flutter and the Google Calendar API. Your code looks mostly correct, but there are a few potential issues that could be causing the conference data not to be generated:

Missing Permissions: Make sure that the service account you are using has the necessary permissions to create events with conference data. Double-check the service accounts settings in the Google Cloud Console.

Calendar Settings: Ensure that the calendar you are inserting the event into allows for conference data. Some calendars may have restrictions on adding conference details.

Conference Solution Key: The conferenceSolutionKey in the createRequest might need to include additional parameters. You can refer to the official documentation for more details.

Error Handling: Check the error logs and see if any errors are being thrown during the event creation process. Your catch block should catch any errors and print them out, which can help diagnose issues.

API Version: Ensure that youre using the correct API version. Google sometimes updates their APIs, so its essential to check the latest documentation to see if any changes have been made.

Heres a modified version of your code with some additional error handling and logging to help diagnose the issue:

darttry { // Your existing code here... // Insert the event final createdEvent = await calendarApi.events.insert( event, primary, // Use primary for the authenticated users primary calendar conferenceDataVersion: 1, ); // Log information about the created event print("Hangout Link: ${createdEvent.hangoutLink}"); print("Event ID: ${createdEvent.id}"); print("Conference Data Status Code: ${createdEvent.conferenceData?.createRequest?.status?.statusCode}"); print("Event Status: ${createdEvent.status}"); print("Event Creator Email: ${createdEvent.creator?.email}"); return createdEvent; } catch (error, stackTrace) { print(Error creating event: $error); print(Stack trace: $stackTrace); rethrow; // Rethrow the error to propagate it }

This modified code should help you identify any errors or issues that are preventing the conference data from being generated.