-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathClickUp-AddComment.ps1
More file actions
104 lines (69 loc) · 2.37 KB
/
ClickUp-AddComment.ps1
File metadata and controls
104 lines (69 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<#
.NOTES
===========================================================================
Created by: James Krolik
Created on: 05/25/2021
Updated on: 05/25/2021
Filename: ClickUp-AddComment.ps1
===========================================================================
.DESCRIPTION
This script is part of a collection of scripts meant to interact with ClickUp.
This script is intended to add comments to an existing ticket.
Additionally, the script can accept a parameter to use the Custom Ticket ID's (XX-XXXXX) identifier by passing in -customID with $true.
.USAGE
ClickUp-AddComment.ps1 -ticket "a1b2c3d" -comment "The server is now back online."
.ADDITIONAL NOTES
For ClickUp's API, please see their website here:
https://clickup.com/api
This was built with the OAuth2 authorization code and access token steps in mind.
You could also sub out the access token with the personal key that they mention (pk_) and it would work just the same as the authorization key.
#>
<##########################
Site Specific Information
###########################>
$authorizationKey = ""
$teamID = ""
<#######################
# Parameter Block #
#######################>
Param(
[Parameter(Mandatory=$true)]
[String]$taskID,
[Parameter(Mandatory=$true)]
[String]$comment,
[Parameter(Mandatory=$false)]
[Bool]$customID=$false
)
<#######################
# Header Block #
#######################>
$headers = @{
Authorization=$authorizationKey
"Content-Type" = "application/json"
}
<######################
Comment Payload
######################>
$body = ""
$body = @{
comment_text=$comment
}
<####################
Parameter Payload
####################>
if ($customID -eq $true) {
$SendParameters = @{
"URI"="https://api.clickup.com/api/v2/task/$taskID/comment?custom_task_ids=true&team_id=$teamID"
"Method"= 'POST'
}
$json = $body | ConvertTo-Json
Invoke-RestMethod @SendParameters -headers $headers -Body $json
}
if ($customID -eq $false) {
$SendParameters = @{
"URI"="https://api.clickup.com/api/v2/task/$taskID/comment?"
"Method"= 'POST'
}
$json = $body | ConvertTo-Json
Invoke-RestMethod @SendParameters -headers $headers -Body $json
}