-
Notifications
You must be signed in to change notification settings - Fork 72
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
Invoke-MSGraphRequest not converting content correctly. #54
Comments
happening to me too |
@cconrado if your input is in json format try this i.e. add ".toString() to the Content, it should work: $IOSF = $IOSF | ConvertTo-Json Invoke-MSGraphRequest -Url $URL -HttpMethod PATCH -Content $IOSF.toString() |
@davefalkus I got it to working using this $json = @" I didn't need to convert. |
@cconrado if you declare the json as you have your correct you don't need to convert it to string, but if you have a PS object which you convert to json, then the carriage return and new line /r/n are added which the commandlet can't parse, so the tostring() can be used to work around it. |
@davefalkus good tip thanks for that. Learning more everyday :) |
Hey,
Its my understanding that Content will accept, Hash, Object, or a String.
The command i am using is:
Invoke-MSGraphRequest -Url $URL -HttpMethod PATCH -Content $IOSF -Debug -Verbose
If i pass a HASH i get this(Not Complete)
{"contentFilterSettings":{"CliXml":"<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04\">\r\n <Obj RefId="0">\r\n <TN RefId="0">\r\n
System.Management.Automation.PSCustomObject\r\n
If I pass an object, the body is empty
$IOSF = $IOSF | ConvertTo-Json | ConvertFrom-Json ##Convert hash to object
If i pass a string(Not Complete)
$IOSF = $IOSF | ConvertTo-Json
"{\r\n "contentFilterSettings": {\r\n "@odata.type": "#microsoft.graph.iosWebContentFilterAutoFilter",\r\n
"allowedUrls": [\r\n\r\n ],\r\n "blockedUrls": [\r\n
"https://facebook.com",\r\n "http://facebook.com",\r\n
"https://instagram.com",\r\n "http://instagram.com",\r\n
"https://mail.google.com",\r\n "http://mail.google.com",\r\n
"https://twitter.com",\r\n
How i was able to get it to work
$($($IOSF | ConvertTo-Json) -replace "
r
n","" -replace " ","")PS Version: 5.1.17763.503
Module Version: 6.1902.1.10
The text was updated successfully, but these errors were encountered: