Skip to content

Change buckets #12

@msiejda

Description

@msiejda

Are You still developing this module? Change buckets are missing.

I have w http request that works with user cerdentials (I'm not sure if it works due to permission settings ):

PATCH https://graph.microsoft.com/v1.0/planner/buckets/{['id']}
{
  "content-type": "application/json",
  "Authorization": "{('AuthorizationHeader')}",
  "If-Match": {['@odata.etag']}
}

{
  "name": "{['New bucket name']}"
}

Maybe it should look something like this:

Function Invoke-PlannerBucket
{
	# .ExternalHelp PlannerModule.psm1-Help.xml
	
	[CmdletBinding()]
	param
	(
		[Parameter(Mandatory = $True, ValueFromPipelineByPropertyName = $True, ParameterSetName = 'BucketID')]
		[Alias("id")]
		$BucketID,
		[Parameter(Mandatory = $True)]
		[string[]]$Title,
		[bool]$IsChecked = $false
	)
	
	#Get Task details
	$respond = Get-PlannerBucket -BucketID $BucketID
	$ETag = $respond.'@odata.etag'
	
	$Body = @"
{
  "name": "$($Title)"
}
"@
	
	#Add if-match to new tocket header
	$NewToken = $authToken.Clone()
	$NewToken.add("If-Match", $ETag)
	
	try
	{
		$uri = "https://graph.microsoft.com/v1.0/planner/buckets/$($BucketID)"
		Invoke-RestMethod -Uri $uri -Headers $NewToken -Method PATCH -Body $Body
		Write-Host "Bucket name changed to $($Title)" -ForegroundColor Cyan
	}
	catch
	{
		$ex = $_.Exception
		if ($($ex.Response.StatusDescription) -match 'Unauthorized')
		{
			Write-Error "Unauthorized, Please check your permissions and use the 'Connect-Planner' command to authenticate"
		}
		Write-Error "Request to $Uri failed with HTTP Status $($ex.Response.StatusCode) $($ex.Response.StatusDescription)"
		break
	}
	
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions