MicrosoftGraph.Request (Microsoft Graph API Client v0.2.0)

Lower-level API to create and execute Microsoft Graph API requests.

Link to this section Summary

Functions

Create a DELETE request.

Executes a given request.

Create a GET request.

Create a request. You generally should use the other request constructors like get/2 and post/2.

Will make request a paginated request. execute/2 will follow the @odata.nextLink in the response if it exists to fetch the next page. Method type will be :get_paginated.

Create a PATCH request.

Create a POST request.

Create a PUT request.

Puts the advanced query params and headers required for some operations.

Puts a header into the given request.

Link to this section Types

@type t() :: %MicrosoftGraph.Request{
  headers: [{binary(), binary()}],
  method: atom(),
  options: [cast: atom(), merge_query_params: boolean()],
  params: map(),
  url: URI.t()
}

Link to this section Functions

Link to this function

delete(path, options \\ [])

Create a DELETE request.

See new/1 for options.

Link to this function

execute(request, client)

Executes a given request.

example

Example

iex> MicrosoftGraph.Request.execute(%Request{}, %OAuth2.Client{})
{:ok, response}

# Bad request
iex> MicrosoftGraph.Request.execute(%Request{}, %OAuth2.Client{})
{:error, response}

# Unsupported method
iex> MicrosoftGraph.Request.execute(%Request{method: :grab}, %OAuth2.Client{})
{:error, :unsupported_method}
Link to this function

get(path, options \\ [])

Create a GET request.

See new/1 for options.

Link to this function

new(options \\ [])

Create a request. You generally should use the other request constructors like get/2 and post/2.

Basic request options:

  • :method - the request method, defaults to :get.
  • :url - the request URL.
  • :headers - the request headers. The headers are automatically encoded using these rules:
    • atom header names are turned into strings
    • string header names are left as is.
  • :params - the request params (querystring for get, post body for post,put,patch).
  • :cast - OData cast, defaults to nothing Options are:
    • :user for microsoft.graph.user
    • :group for microsoft.graph.group
Link to this function

paginate_results(request)

Will make request a paginated request. execute/2 will follow the @odata.nextLink in the response if it exists to fetch the next page. Method type will be :get_paginated.

Link to this function

patch(path, options \\ [])

Create a PATCH request.

See new/1 for options.

Link to this function

post(path, options \\ [])

Create a POST request.

See new/1 for options.

Link to this function

put(path, options \\ [])

Create a PUT request.

See new/1 for options.

Link to this function

put_advanced_query_params(request)

Puts the advanced query params and headers required for some operations.

https://docs.microsoft.com/en-us/graph/aad-advanced-queries?tabs=http

Link to this function

put_header(request, key, value)

Puts a header into the given request.

example

Example

iex> MicrosoftGraph.Request.put_header(%Request{}, "Content-Type", "application/json")
%Request{}