Skip to content

When a dictionary to the body object we should translate it to JSON instead of form encoding it. #327

Closed

Description

@georgend

When a Dictionary is passed to body object, in a POST request, translate it to JSON instead of form encoding it.

PS> Invoke-GraphRequest -Method POST -Uri https://graph.microsoft.com/beta/teams/id/members 
-body @{ "@odata.type"="#microsoft.graph.aadUserConversationMember";
                  "roles"=@("owners"); 
                   "users@odata.bind"="https://graph.microsoft.com/beta/users/{GUID}"
              } 
-Debug -ContentType "application/json"

VERBOSE: POST https://graph.microsoft.com/beta/teams/id/members with 191-byte payload

DEBUG: POST /beta/teams/id/members HTTP/1.1
HTTP: graph.microsoft.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Microsoft Windows 10.0.18363; en-CA) PowerShell/7.0.2 Invoke-GraphRequest
Content-Length: 191
Content-Type: application/json
roles=System.Object%5B%5D&%40odata.type=%23microsoft.graph.aadUserConversationMember&users%40odata.bind=https%3A%2F%2Fgraph.microsoft.com%2Fbeta%2Fusers%{GUID}
VERBOSE: received 310-byte response of content type application/json
DEBUG: HTTP/1.1 400 Bad Request

It should be serialized as follows
image

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions