Project

General

Profile

Rest api with powershell » History » Revision 2

Revision 1 (Seung Soo Mun, 2019-02-22 12:38) → Revision 2/11 (Seung Soo Mun, 2019-02-22 12:41)

h1. Using the REST API with Powershell 

 h2. *Powershell*: 

 <pre> 
 $Cred = Get-Credential 

 Invoke-RestMethod http://demo.redmine.org/issues/12345.json -Credential $Cred 
 Invoke-RestMethod http://demo.redmine.org/projects/12.json -Credential $Cred 
 Invoke-RestMethod http://demo.redmine.org/versions/123.json -Credential $Cred 

 (Invoke-RestMethod http://demo.redmine.org/issues.json -Credential $Cred).issues 
 (Invoke-RestMethod http://demo.redmine.org/projects.json -Credential $Cred).projects 
 (Invoke-RestMethod http://demo.redmine.org/projects/12/versions.json -Credential $Cred).versions 

 Invoke-RestMethod http://demo.redmine.org/projects/12.json -Credential $Cred -Method PUT -ContentType 'application/json' -Body '{"project": {"default_version_id": "398"}}' 
 Invoke-RestMethod http://demo.redmine.org/projects/testproject.json -Credential $Cred -Method PUT -ContentType 'application/json' -Body '{"project": {"default_version_id": "398"}}' 

 Invoke-RestMethod http://demo.redmine.org/projects/12/versions.json -Credential $Cred -Method POST -ContentType 'application/json' -Body '{"version": {"name": "Test ver", "description": "Test version desc"}}' 
 Invoke-RestMethod http://demo.redmine.org/issues.json -Credential $Cred -Method POST -ContentType 'application/json' -Body '{"issue": {"project_id": 438, "subject": "test watchers", "watcher_user_ids": [7,11,110]}}' 
 </pre> 

 h2. *PSRedmine*: 

 https://github.com/hamletmun/PSRedmine 

 <pre> 
 Connect-Redmine demo.redmine.org 

 New-RedmineResource project -identifier test99 -name testproject 
 New-RedmineResource version -project_id 475 -name testversion 
 New-RedmineResource issue -project_id test99 -subject testissue 

 Search-RedmineResource project -keyword testproject 
 Search-RedmineResource membership -project_id test99 
 Search-RedmineResource version -project_id test99 -keyword testversion  
 Search-RedmineResource issue -keyword testissue 
 Search-RedmineResource user -keyword testuser # Administrator only 

 Get-RedmineResource project test99 
 Get-RedmineResource project 475 
 Get-RedmineResource membership 74 
 Get-RedmineResource version 408 
 Get-RedmineResource issue 29552 
 Get-RedmineResource user 20 # Administrator only 

 Edit-RedmineResource project -id test99 -description 'change description' 
 Edit-RedmineResource version -id 408 -description 'add desc' -due_date 2018-09-29 
 Edit-RedmineResource issue -id 29552 -version_id 406 

 Remove-RedmineResource issue 29552 
 Remove-RedmineResource version 408 
 Remove-RedmineResource project test99 # Administrator only 
 Remove-RedmineResource user 20 # Administrator only 

 Disconnect-Redmine 
 </pre>