microsoftgraph / msgraph-sdk-ruby

Microsoft Graph Ruby client library for v1 APIs
https://graph.microsoft.com
MIT License
99 stars 68 forks source link

Can't find documentation for fetching #205

Closed amitleshed closed 1 month ago

amitleshed commented 1 month ago

Where can I find the docs for simple client api calls like such as:

    response = @client.me.calendar_view.get(
      query_parameters: {
        'startDateTime' => start_time,
        'endDateTime' => end_time,
        '$orderby' => 'start/dateTime'
      }
    )

The code I provided doesn't work, as it accepts a method "headers" so I assume I'm missing a usage of some class.

Here's how I initialized the client

context = MicrosoftKiotaAuthenticationOAuth::ClientCredentialContext.new(
      TENANT_ID, CLIENT_ID, CLIENT_SECRET
    )

    @authentication_provider = MicrosoftGraphCore::Authentication::OAuthAuthenticationProvider.new(
      context, nil, SCOPES
    )

    adapter = MicrosoftGraph::GraphRequestAdapter.new(@authentication_provider)
    @client = MicrosoftGraph::GraphServiceClient.new(adapter) 

All I really need is the ruby-sdk method documentation/examples which I can't find. Just found the rubyonrails example app but it doesn't use the sdk, only uses straight http calls to microsoft-graph.

Thanks.

baywet commented 1 month ago

Hi @amitleshed Thank you for using the Ruby SDK and for reaching out

Have you tried something like this?

response = @client.me.calendar_view.get({
      query_parameters: CalendarViewRequestBuilderGetQueryParameters.new {
        start_date_time: start_time,
        end_date_time: end_time,
        orderby: 'start/dateTime'
      }
    })
amitleshed commented 1 month ago

Hey! thanks a lot, I have tried this, but still get a NoMethodError

(undefined method 'headers' for {:query_parameters=>#<MicrosoftGraph::Me::Calendar::CalendarView::CalendarViewRequestBuilder::CalendarViewRequestBuilderGetQueryParameters:0x000000011cf745f0 @start_date_time=2024-05-12 00:00:00 -0400, @end_date_time=2024-05-19 00:00:00 -0400, @orderby="start/dateTime">}:Hash):

Not sure what am I doing wrong. Are there any usage examples of the SDK?

baywet commented 1 month ago

ok, let's try this then

response = @client.me.calendar_view.get(RequestConfiguration.new {
      query_parameters: CalendarViewRequestBuilderGetQueryParameters.new {
        start_date_time: start_time,
        end_date_time: end_time,
        orderby: 'start/dateTime'
      }
    })

Request configuration comes from here

amitleshed commented 1 month ago

Thank you! that makes sense, I guess I missed this class.

That moves me forward a step, as now I'm encountering a MicrosoftGraph::Models::ODataErrorsODataError when I try to response.resume.

Anyways, I suspect it might be an Azure permission issue, so I'll explore this. Really appreciate your response, I also plan to write a little example flow once I make this work. Thanks a lot!

baywet commented 1 month ago

Thanks for confirming! Closing.