Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Invoke-GraphRequest fails with BadRequest for PUT Requests #486

Merged
merged 1 commit into from
Dec 10, 2020

Conversation

georgend
Copy link
Contributor

@georgend georgend commented Dec 9, 2020

Original Issue

else if (Method == GraphRequestMethod.POST)
{
GraphRequestSession.ContentHeaders.TryGetValue(HttpKnownHeaderNames.ContentType, out var contentType);
if (string.IsNullOrWhiteSpace(contentType))
{
// Assume application/json if not set by user
GraphRequestSession.ContentHeaders[HttpKnownHeaderNames.ContentType] =
CoreConstants.MimeTypeNames.Application.Json;
}

Line above only defaulted the Content-Type to application/json for POST only.

Fix
Set default Content-Type header to application/json when user has not specified -ContentType for PUT,POST,PATCH requests.

Fixes #483

… specified `-ContentType` for PUT,POST,PATCH.
@georgend georgend requested a review from peombwa December 9, 2020 23:37
@georgend georgend self-assigned this Dec 9, 2020
@georgend georgend added this to the 1.3.0 milestone Dec 9, 2020
@georgend georgend added the Bug label Dec 9, 2020
@georgend georgend merged commit 437e8bf into dev Dec 10, 2020
@peombwa peombwa deleted the bug/putRequests branch December 11, 2020 19:53
@peombwa peombwa mentioned this pull request Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

extend Invoke-MgGraphRequest to handle PUT body / Unauthorized during build
2 participants