Created
March 23, 2023 17:13
-
-
Save cezarypiatek/78cb352d4bb79fc8330ca558c3ce4942 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[Parameter(Mandatory=$true)] | |
[string]$apiKey, | |
[Parameter(Mandatory=$true)] | |
[string]$issueKey, | |
[Parameter(Mandatory=$true)] | |
[string]$timeSpent, | |
[DateTime]$startDate = (Get-Date).Date | |
) | |
# Set up variables for JIRA API endpoint and the date in ISO-8601 format | |
$apiEndpoint = "https://your-jira-instance.com/rest/api/2/issue/" | |
$dateString = $startDate.ToString("yyyy-MM-ddTHH:mm:ss.fffzzz") | |
# Set up authentication headers for JIRA | |
$headers = @{ | |
"Authorization" = "Bearer $apiKey" | |
"Content-Type" = "application/json" | |
} | |
# Build the JSON payload for the JIRA API call | |
$json = @{ | |
timeSpent = $timeSpent | |
started = $dateString | |
} | ConvertTo-Json | |
# Make the JIRA API call to report work time | |
$response = Invoke-RestMethod -Method POST -Uri ($apiEndpoint + $issueKey + "/worklog") -Headers $headers -Body $json | |
# Output the response from JIRA | |
$response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment