Skip to content

Cannot process argument transformation on parameter 'Body'. Cannot convert the "<h1>Hello</h1>" value of type | "System.String" to type "Microsoft.Graph.PowerShell.Models.IMicrosoftGraphItemBody" #339

Closed

Description

@thenecroscope

After upgrading from 0.7.1 to 0.9.1 my scripts are now failing when trying to send a simple HTML message.

Cannot process argument transformation on parameter 'Body'. Cannot convert the "Hello World" value of type
| "System.String" to type "Microsoft.Graph.PowerShell.Models.IMicrosoftGraphItemBody"

Looks as though the parameters options have now changes from -BodyContent to -Body.

Activity

  1. thenecroscope commented on Aug 17, 2020

    @thenecroscope
    Author

    The examples will probably need to be updated here also:
    https://github.com/microsoftgraph/msgraph-sdk-powershell/blob/dev/samples/5-Teams.ps1

    thanks again

  2. thenecroscope commented on Aug 17, 2020

    @thenecroscope
    Author

    If I try this, I'm hitting the following error:

    New-MgTeamChannelMessage -ChannelId $teamsConfigItemChannelID -TeamId $teamsConfigItemTeamID -Body @{content = "hello"}

    Line |
    12353 | $scriptCmd = {& $wrappedCmd @PSBoundParameters}
    | ~~~~~~~~~~~~~~~~~~
    | Cannot bind parameter 'Body'. Cannot convert the "Microsoft.Graph.PowerShell.Models.MicrosoftGraphItemBody"
    | value of type "Microsoft.Graph.PowerShell.Models.MicrosoftGraphItemBody" to type
    | "Microsoft.Graph.PowerShell.Models.IMicrosoftGraphItemBody".

  3. peombwa commented on Aug 18, 2020

    @peombwa
    Member

    Thanks for reporting this bug. We've traced this issue to our code generator which expects content to start with uppercase C i.e. Content.

    We are currently working on fix for this. A temporary workaround is to ensure your property names are in PascalCase.

    New-MgTeamChannelMessage -ChannelId $ChannelId -TeamId $teamId -BodyParameter @{Body = @{Content = "hello"}} -Debug

    or

    New-MgTeamChannelMessage -ChannelId $ChannelId -TeamId $teamId -Body @{Content = "hello"} -AdditionalProperties @{} -Debug
  4. thenecroscope commented on Aug 18, 2020

    @thenecroscope
    Author

    Thanks Peter for the response. I'm still not having much luck using Pascal Case I'm afraid. I've copied both examples (thanks for the tip RE: debug and the alternative way of sending the message) but I'm now getting a new error.

    I've tried PS5.1 and 7.1 P6, but they both are giving me the same error:

    New-MgTeamChannelMessage_CreateExpanded1: C:\Users\xxxx\Documents\PowerShell\Modules\Microsoft.Graph.Teams.Team\0.9.1\exports\v1.0-beta\ProxyCmdletDefinitions.ps1:12353:23
    Line |
    12353 | $scriptCmd = {& $wrappedCmd @PSBoundParameters}
    | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    | An item with the same key has already been added. Key: content

    thoughts?
    thanks again

  5. jasonjoh commented on Aug 19, 2020

    @jasonjoh
    Member

    Peter Ombwa (@peombwa) I reproduce what thenecroscope is seeing as well using the two workaround commands you posted above. Let me know if I can help provide any further information.

  6. peombwa commented on Sep 29, 2020

    @peombwa
    Member

    This was fixed with 1.0.1. Install-Module Microsoft.Graph -AllowClobber -Force.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions