Code Monkey home page Code Monkey logo

msgraph-beta-sdk-ruby's Introduction

Microsoft Graph Beta SDK for Ruby

Get started with the Microsoft Graph Beta SDK for Ruby by integrating the Microsoft Graph API into your Ruby application!

Note: this SDK allows you to build applications using the beta of Microsoft Graph. If you want to use the production supported Microsoft Graph APIs under v1.0, use our v1.0 SDK instead.

Note: the Microsoft Graph Ruby SDK is currently in Community Preview. During this period we're expecting breaking changes to happen to the SDK based on community's feedback. Checkout the known limitations.

1. Installation

run gem install microsoft_graph_beta or include gem microsoft_graph_beta in your gemfile.

2. Getting started

2.1 Register your application

Register your application by following the steps at Register your app with the Microsoft Identity Platform.

2.2 Create an AuthenticationProvider object

An instance of the MicrosoftGraphServiceClient class handles building client. To create a new instance of this class, you need to provide an instance of AuthenticationProvider, which can authenticate requests to Microsoft Graph.

For an example of how to get an authentication provider, see choose a Microsoft Graph authentication provider.

Note: we are working to add the getting started information for Ruby to our public documentation, in the meantime the following sample should help you getting started.

require "microsoft_kiota_authentication_oauth"
require "microsoft_graph_core"

context = MicrosoftKiotaAuthenticationOAuth::ClientCredentialContext.new("<the tenant id from your app registration>", "<the client id from your app registration>", "<the client secret from your app registration>")

authentication_provider = MicrosoftGraphCore::Authentication::OAuthAuthenticationProvider.new(context, nil, ["Files.Read"])

2.3 Get a Graph Service Client and Adapter object

You must get a MicrosoftGraphServiceClient object to make requests against the service.

require "microsoft_graph_beta"

adapter = MicrosoftGraphBeta::MicrosoftGraphRequestAdapter.new(authentication_provider)
client = MicrosoftGraphBeta::MicrosoftGraphServiceClient.new(adapter)

3. Make requests against the service

After you have a MicrosoftGraphServiceClient that is authenticated, you can begin making calls against the service. The requests against the service look like our REST API.

3.1 Get the user's drive

To retrieve the user's drive:

result = client.me.drive.get.resume
puts "Found Drive : " + result.id

4. Getting results that span across multiple pages

Automatic paging is currently not supported with the Ruby SDK, we're working to enable this feature.

5. Documentation

For more detailed documentation, see:

6. Issues

For known issues, see issues.

7. Contributions

The Microsoft Graph SDK is open for contribution. To contribute to this project, see Contributing.

8. License

Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT license.

9. Third-party notices

Third-party notices

msgraph-beta-sdk-ruby's People

Contributors

baywet avatar dependabot[bot] avatar fey101 avatar github-actions[bot] avatar michaelmainer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msgraph-beta-sdk-ruby's Issues

Body for GetPresencesByUserId blank

I have the following code:

context = MicrosoftKiotaAuthenticationOAuth::ClientCredentialContext.new(
  ENV.fetch("MICROSOFT_TENANT_ID"),
  ENV.fetch("MICROSOFT_CLIENT_ID"),
  ENV.fetch("MICROSOFT_CLIENT_SECRET")
)

authentication_provider = MicrosoftGraphCore::Authentication::OAuthAuthenticationProvider.new(context, nil, ["https://graph.microsoft.com/.default"])

adapter = MicrosoftGraphBeta::GraphRequestAdapter.new(authentication_provider)
client = MicrosoftGraphBeta::GraphServiceClient.new(adapter)

begin
  body = MicrosoftGraphBeta::Communications::GetPresencesByUserId::GetPresencesByUserIdPostRequestBody.new
  body.ids = users.collect { |user| user[:id] }
  request = client.communications.get_presences_by_user_id.post(body)

  result = request.resume
rescue => e
  puts e.error
end

Note: I'm not showing the list of users above, but users is an array of hashes I'm pulling from for testing this example.

But it outputs:

#<MicrosoftGraphBeta::Models::ODataErrorsMainError:0x0000ffff92322638
 @additional_data={},
 @code="InvalidArgument",
 @inner_error=
  #<MicrosoftGraphBeta::Models::ODataErrorsInnerError:0x0000ffff92322368 
  @additional_data={"date"=>"2024-06-05T15:00:32"}, 
  @client_request_id="<REDACTED>", 
  @request_id="<REDACTED>">,
  @message="[ids]: Required property 'ids' not found in JSON. Path '', line 1, position 2.">

If I look at the body I will see the ids in the array, but for some reason serialization isn't working?

I tested the serializer and that seems to work fine, but its something about GetPresencesByUserIdRequestBuilder.to_post_request_information#56 as the line seems to the what actually uses it, but the content if I manually call it :

ri = client.communications.get_presences_by_user_id.to_post_request_information(body)

is blank:

irb(main):255> ri.inspect
=> "#<MicrosoftKiotaAbstractions::RequestInformation:0x0000ffff974b89e8 @headers=#<MicrosoftKiotaAbstractions::RequestHeaders:0x0000ffff974bfb80 
  @headers={\"Accept\"=>[\"application/json\"], \"Content-Type\"=>[\"application/json\"]}>, 
  @query_parameters={}, 
  @path_parameters={\"baseurl\"=>\"https://graph.microsoft.com/beta\"}, 
  @url_template=\"{+baseurl}/communications/getPresencesByUserId\", 
  @http_method=:POST, 
  @content=\"{}\">"

I'm not sure if I'm doing something wrong or this is broken. Let me know if you need more details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.