Skip to content

Invoke-RestMethod PUT fails #9473

@Agazoth

Description

@Agazoth

Steps to reproduce

 $Header = @{
Authorization = "Basic <MyToken>"
"Content-Type" =  "application/json"
}
Invoke-RestMethod -Uri https://MyOrg.freshservice.com/api/v2/assets/1511/delete_forever -headers $header -method PUT

Expected behavior


The API returns nothing when deleting an entry

Actual behavior

Invoke-RestMethod : {"message":"Content-Type header should have application/json","code":"invalid_content_type"}
At line:1 char:1
+ Invoke-RestMethod @Params
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (Method: PUT, Reques\u2026PowerShell/6.2.0
}:HttpRequestMessage) [Invoke-RestMethod], HttpResponseException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Environment data

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.2.0
PSEdition                      Core
GitCommitId                    6.2.0
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions