Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marckean/6934cbc3e3a796c3aa0df2678d68c9a2 to your computer and use it in GitHub Desktop.
Save marckean/6934cbc3e3a796c3aa0df2678d68c9a2 to your computer and use it in GitHub Desktop.
#########################################################
####### only works if the Route template is blank #######
#########################################################
# QUERY based parameter values - GET method
$firstName = 'Marc'
$surName = 'Kean'
$iwr = Invoke-WebRequest -Uri "https://ejuke2.azurewebsites.net/api/blog?firstname=$firstName&surname=$surName" -Method Get
$iwr.content
# BODY based parameter values - POST method
$firstName = 'Marc'
$surName = 'Kean'
$postParams = @{"firstname" = $firstName;"surName" = $surName} | ConvertTo-Json
$iwr = Invoke-WebRequest -Uri "https://ejuke2.azurewebsites.net/api/blog" -Method POST -Body $postParams
$iwr.content
#########################################################
##### only works if the Route template is NOT blank #####
#########################################################
# Route Template: RouteName/{firstname}/{surname}
# PARAMS path based parameter values - GET method
$firstName = 'Marc'
$surName = 'Kean'
$iwr = Invoke-WebRequest -Uri "https://ejuke2.azurewebsites.net/api/RouteName/$firstName/$surName" -Method Get
$iwr.content
# PARAMS path based parameter values - POST method
$firstName = 'Marc'
$surName = 'Kean'
$iwr = Invoke-WebRequest -Uri "https://ejuke2.azurewebsites.net/api/RouteName/$firstName/$surName" -Method POST
$iwr.content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment