Project

General

Profile

Actions

Rest api with powershell » History » Revision 8

« Previous | Revision 8/11 (diff) | Next »
Seung Soo Mun, 2022-03-10 20:54


Using the REST API with Powershell

Powershell

Invoke-RestMethod cmdlet

Invoke-RestMethod http://demo.redmine.org/issues/12345.json?key=a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0
Invoke-RestMethod http://demo.redmine.org/projects/12.json?key=a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0
Invoke-RestMethod http://demo.redmine.org/versions/123.json?key=a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0

Invoke-RestMethod -Headers @{'X-Redmine-API-Key'='a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0'} http://demo.redmine.org/issues/12345.json
Invoke-RestMethod -Headers @{'X-Redmine-API-Key'='a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0'} http://demo.redmine.org/projects/12.json
Invoke-RestMethod -Headers @{'X-Redmine-API-Key'='a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0'} http://demo.redmine.org/versions/123.json

$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]}}'

using PSRedmine module

https://github.com/hamletmun/PSRedmine

Example

using Redmine-net-api dll

https://github.com/JamesNK/Newtonsoft.Json
https://github.com/zapadi/redmine-net-api

Example

Updated by Seung Soo Mun over 2 years ago · 8 revisions