Forum Discussion

supportsib's avatar
supportsib
Brass Contributor
Aug 17, 2021

400 Bad request

Hi,

 

$oauthUri = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token"

# Create token request body
$tokenBody = @{
client_id = $graphApiDemoAppId
client_secret = $graphApiDemoAppSecret
scope = "https://graph.microsoft.com/.default"
grant_type = "client_credentials"
}


$tokenRequest = Invoke-RestMethod -Uri $oauthUri -Method POST -ContentType "application/x-www-form-urlencoded" -Body $tokenBody -UseBasicParsing


$accessToken = ($tokenRequest).access_token

$headers = @{
"Authorization" = "Bearer $accessToken"
"Content-type" = "application/json"
}

$teambody =
'{
"displayName": "Architecture Team1",
"description": "The team for those in architecture design.",

"template@odata.bind" : [
"https://graph.microsoft.com/v1.0/teamsTemplates(''standard'')"
],

}'

 

Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/teams" -Method POST -Headers $headers -Body $teambody

 

I am getting 400 bad request error  if  I try to create user , teams.groups ,...

And If I use any  GET method it is working fine 

 

Please ad 

 

No RepliesBe the first to reply

Resources