Запросы к REST API на PowerShell

Содержание
Введение
GET
POST
PUT
DELETE
Другие статьи о PowerShell

Введение

GET

$headers=@{} $headers.Add("accept", "application/json") $headers.Add("Authorization", "Bearer a-proper-token-goes-here") $response = Invoke-WebRequest -Uri 'https://example.com/engine/api/v1/wfs' -Method GET -Headers $headers

Banner image

POST

$headers=@{} $headers.Add("accept", "application/json") $headers.Add("Authorization", "Bearer a-proper-token-goes-here") $headers.Add("content-type", "application/json") $response = Invoke-WebRequest -Uri 'https://example.com/engine/api/v1/wfs' -Method POST -Headers $headers -ContentType 'application/json' -Body '{"status":"WAITING","approver_can_revoke":true,"target_role_revoked":false,"can_bypass_revoke_wf":false,"steps":[{"name":"step"}],"name":"name"}'

PUT

$headers=@{} $headers.Add("accept", "application/json") $headers.Add("Authorization", "Bearer a-proper-token-goes-here") $headers.Add("content-type", "application/json") $response = Invoke-WebRequest -Uri 'https://example.com/engine/api/v1/wfs/wf_id' -Method PUT -Headers $headers -ContentType 'application/json' -Body '{"status":"WAITING","approver_can_revoke":true,"target_role_revoked":false,"can_bypass_revoke_wf":false,"steps":[{"name":"step"}],"name":"name"}'

DELETE

$headers=@{} $headers.Add("accept", "application/json") $headers.Add("Authorization", "Bearer a-proper-token-goes-here") $response = Invoke-WebRequest -Uri 'https://example.com/engine/api/v1/wfs/wf_id' -Method DELETE -Headers $headers

Article author: Andrei Olegovich

Похожие статьи
Windows
PowerShell
Install
Basics
Alias
Functions
Network
Users
Files
REST API requests
Errors
Banner image

Search this site

Subscribe to Telegram channel @aofeed to follow new articles and updates to old ones

Go to channel

@aofeed

Ask a question in the Telegram group

@aofeedchat

Contacts and cooperation:
I recommend our hosting beget.ru
Write to info@urn.su, info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: