Skip to content

Commit

Permalink
Add Put method to 'Graph Client' Codeunit
Browse files Browse the repository at this point in the history
  • Loading branch information
devgar committed Mar 14, 2024
1 parent 9386838 commit 8d44f6f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ codeunit 9350 "Graph Client"
exit(GraphClientImpl.Patch(RelativeUriToResource, GraphOptionalParameters, RequestHttpContent, HttpResponseMessage));
end;

/// <summary>
/// Put any request to the microsoft graph API
/// </summary>
/// <remarks>Does not require UI interaction.</remarks>
/// <param name="RelativeUriToResource">A relativ uri including the resource segment</param>
/// <param name="GraphOptionalParameters">A wrapper for optional header and query parameters</param>
/// <param name="RequestHttpContent">The HttpContent object for the request.</param>
/// <param name="HttpResponseMessage">The response message object.</param>
/// <returns>True if the operation was successful; otherwise - false.</returns>
/// <error>Authentication failed.</error>
procedure Put(RelativeUriToResource: Text; GraphOptionalParameters: Codeunit "Graph Optional Parameters"; RequestHttpContent: Codeunit "Http Content"; var HttpResponseMessage: Codeunit "Http Response Message"): Boolean
begin
exit(GraphClientImpl.Put(RelativeUriToResource, GraphOptionalParameters, RequestHttpContent, HttpResponseMessage));
end;

/// <summary>
/// Send a DELETE request to the microsoft graph API
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ codeunit 9351 "Graph Client Impl."
exit(HttpResponseMessage.GetIsSuccessStatusCode());
end;

procedure Put(RelativeUriToResource: Text; GraphOptionalParameters: Codeunit "Graph Optional Parameters"; RequestHttpContent: Codeunit "Http Content"; var HttpResponseMessage: Codeunit "Http Response Message"): Boolean
var
GraphUriBuilder: Codeunit "Graph Uri Builder";
begin
GraphUriBuilder.Initialize(MicrosoftGraphBaseUrl, GraphAPIVersion, RelativeUriToResource, GraphOptionalParameters.GetQueryParameters());
GraphRequestHelper.SetRestClient(RestClient);
HttpResponseMessage := GraphRequestHelper.Put(GraphUriBuilder, GraphOptionalParameters, RequestHttpContent);
exit(HttpResponseMessage.GetIsSuccessStatusCode());
end;

procedure Delete(RelativeUriToResource: Text; GraphOptionalParameters: Codeunit "Graph Optional Parameters"; var HttpResponseMessage: Codeunit "Http Response Message"): Boolean
var
GraphUriBuilder: Codeunit "Graph Uri Builder";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ codeunit 9354 "Graph Request Helper"
HttpResponseMessage := SendRequest(Enum::"Http Method"::PATCH, GraphUriBuilder, GraphOptionalParameters, HttpContent);
end;

procedure Put(GraphUriBuilder: Codeunit "Graph Uri Builder"; GraphOptionalParameters: Codeunit "Graph Optional Parameters"; HttpContent: Codeunit "Http Content") HttpResponseMessage: Codeunit "Http Response Message"
begin
HttpResponseMessage := SendRequest(Enum::"Http Method"::PUT, GraphUriBuilder, GraphOptionalParameters, HttpContent);
end;

procedure Delete(GraphUriBuilder: Codeunit "Graph Uri Builder"; GraphOptionalParameters: Codeunit "Graph Optional Parameters") HttpResponseMessage: Codeunit "Http Response Message"
begin
PrepareRestClient(GraphOptionalParameters);
Expand Down

0 comments on commit 8d44f6f

Please sign in to comment.