Skip to content
Snippets Groups Projects
Commit 76821094 authored by Hans van den Heuvel's avatar Hans van den Heuvel
Browse files

Updated Readme.md

parent be132db3
Branches
No related tags found
No related merge requests found
......@@ -35,15 +35,41 @@ $PSDefaultParameterValues = @{
Happy Powershelling:
```
Get-MCRARepository
Get-MCRARepository|Where Name -match 'agg'
Get-MCRARepository|Where Id -eq 87
Get-MCRAWorkspace|Where Id -eq 87
Get-MCRADataSource|Where Name -match 'agg'|Get-MCRAFile
```
### Questions?
### Which commands are available
```
Get-Command -Module MCRA.Tools
```
### Questions
```
Get-Help Get-MCRARepository -Full
```
### Examples?
### Examples
```
Get-Help Get-MCRARepository -Example
```
# Introduction
## Breakdown of the commands
The commands are essentially a wrapper around the standard Powershell commands.
Say, we want to execute an API call to MCRA, let's take: 'DataSources/GetAll'.
In powershell the following then needs to be executed.
```
# Get token first. Don't change the next line.
$Body = @{ 'grant_type' = 'password' }
# Change the next lines with your own credentials.
$Body['username'] = 'yourusername'
$Body['password'] = 'yourpassword'
$Body['client_id'] = 'yourclient_id'
# Use the proper URL for the website.
$Url='https://mcra.test.wur.nl/Mcra90'
$token=Invoke-RestMethod -Uri "$Url/jwtauth/token" -ContentType 'application/json' -Body $body -Method POST
# Create a proper header for future API calls
$headers = @{ 'authorization' = 'bearer '+$token.access_token }
# Now fetch the actual request from the API.
Invoke-RestMethod -Uri "$Url/Api/DataSources/GetAll" -ContentType 'application/json' -Headers $headers
# Repeat the request with this header until token expires.
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment