Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Trying to automate pulling the licensebased prices every month #414

@freddy-lopez-dev

Description

@freddy-lopez-dev

I was trying to setup an azure Powershell automation with New-PartnerAccessToken trying to invoke-restmethod for pulling up the prices. The access token received from the cmdlet doesn't seem to work and it always gives me a 401 Unauthorized error.

Steps to reproduce

This is my command:
$appId = 'xxxxxxxxxxxx'
$appSecret = 'xxxxxxxxxxx' | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $appId, $appSecret
$token = New-PartnerAccessToken -Credential $credential -Resource https://api.partnercenter.microsoft.com -ServicePrincipal
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer $token")
$response = Invoke-RestMethod 'https://api.partner.microsoft.com/v1.0/sales/pricesheets(Market=''ca'',PricesheetView=''updatedlicensebased'')/$value' -Method 'GET' -Headers $headers

Expected behavior

I should receive the CSV format of product prices

Actual behavior

401 Unauthorized

Environment

Sandbox
5.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions