Rest api with powershell » History » Version 1
Seung Soo Mun, 2019-02-22 12:38
1 | 1 | Seung Soo Mun | h1. Using the REST API with Powershell |
---|---|---|---|
2 | |||
3 | h2. *Powershell*: |
||
4 | |||
5 | <pre> |
||
6 | $Cred = Get-Credential |
||
7 | |||
8 | Invoke-RestMethod http://demo.redmine.org/issues/12345.json -Credential $Cred |
||
9 | Invoke-RestMethod http://demo.redmine.org/projects/12.json -Credential $Cred |
||
10 | Invoke-RestMethod http://demo.redmine.org/versions/123.json -Credential $Cred |
||
11 | |||
12 | (Invoke-RestMethod http://demo.redmine.org/issues.json -Credential $Cred).issues |
||
13 | (Invoke-RestMethod http://demo.redmine.org/projects.json -Credential $Cred).projects |
||
14 | (Invoke-RestMethod http://demo.redmine.org/projects/12/versions.json -Credential $Cred).versions |
||
15 | |||
16 | Invoke-RestMethod http://demo.redmine.org/projects/12.json -Credential $Cred -Method PUT -ContentType 'application/json' -Body '{"project": {"default_version_id": "398"}}' |
||
17 | Invoke-RestMethod http://demo.redmine.org/projects/testproject.json -Credential $Cred -Method PUT -ContentType 'application/json' -Body '{"project": {"default_version_id": "398"}}' |
||
18 | </pre> |
||
19 | |||
20 | h2. *PSRedmine*: |
||
21 | |||
22 | https://github.com/hamletmun/PSRedmine |
||
23 | |||
24 | <pre> |
||
25 | Connect-Redmine demo.redmine.org |
||
26 | |||
27 | New-RedmineResource project -identifier test99 -name testproject |
||
28 | New-RedmineResource version -project_id 475 -name testversion |
||
29 | New-RedmineResource issue -project_id test99 -subject testissue |
||
30 | |||
31 | Search-RedmineResource project -keyword testproject |
||
32 | Search-RedmineResource membership -project_id test99 |
||
33 | Search-RedmineResource version -project_id test99 -keyword testversion |
||
34 | Search-RedmineResource issue -keyword testissue |
||
35 | Search-RedmineResource user -keyword testuser # Administrator only |
||
36 | |||
37 | Get-RedmineResource project test99 |
||
38 | Get-RedmineResource project 475 |
||
39 | Get-RedmineResource membership 74 |
||
40 | Get-RedmineResource version 408 |
||
41 | Get-RedmineResource issue 29552 |
||
42 | Get-RedmineResource user 20 # Administrator only |
||
43 | |||
44 | Edit-RedmineResource project -id test99 -description 'change description' |
||
45 | Edit-RedmineResource version -id 408 -description 'add desc' -due_date 2018-09-29 |
||
46 | Edit-RedmineResource issue -id 29552 -version_id 406 |
||
47 | |||
48 | Remove-RedmineResource issue 29552 |
||
49 | Remove-RedmineResource version 408 |
||
50 | Remove-RedmineResource project test99 # Administrator only |
||
51 | Remove-RedmineResource user 20 # Administrator only |
||
52 | |||
53 | Disconnect-Redmine |
||
54 | </pre> |