Conncet to API via powershell

$apiKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
Invoke-WebRequest -Uri https://eu1.psb.fsapi.com/mp/v1/authentication/login -Method Post -Headers @{ 'x-api-key' = $apiKey ; "username" = "XXXXXXXXXX" ; "password"="XXXXXXXXXXXX" }

 

ITHe Apikey work fine but i get this erro no matter what 

 

{"errors":[{"code":3030,"message":"login.error.badCredentials","lockDuration":1800000,"maxFailedLogins":5}]}

 

i ty this way to

$apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
$Credential = Get-Credential
Invoke-WebRequest -Uri https://eu1.psb.fsapi.com/mp/v1/authentication/login -Method Post -Headers @{ 'x-api-key' = $apiKey } -Credential $Credential

 

 

 

Accepted Answer

Comments

  • This info help alot thx 

  • i get the token fine now but this it's wierd i ty to get companies or any other GET

     

     

    $Token = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

     

    $apiKey = 'XXXXXXXXXXXXXX'
    Write-Output (Invoke-WebRequest -Uri "https://eu1.psb.fsapi.com/mp/v1/partners/102/companies?page=1&perPage=2" -Method Get -Headers @{ 'x-api-key' = $apiKey ; Authorization = "Bearer $Token" }

     

     

    {"errors":[{"code":3030,"message":"login.error.badCredentials"}]}

  • PetriKuikkaPetriKuikka Posts: 216 F-Secure Employee

    Hmm, odd, your call looks really right to me as following curl command works fine:

     

    curl -X GET -H "X-Api-Key: $api-key" -H "Authorization: Bearer $token" "https://eu1.psb.fsapi.com/mp/v1/partners/216/companies?page=1&perPage=max"

     

    Are you sure the 102, is the same partner ID, you login in?

     

    Petri

  • PetriKuikkaPetriKuikka Posts: 216 F-Secure Employee

    I quickly checked our logs and your calls are getting rejected either by following 2 reasons:

     

    "resource":"/mp/v1/partners/102/companies?page=1&perPage=2","message":"No authorization token was found","backendStatus":401

     

    So somehow the token is not in the message.

     

    "resource":"/mp/v1/partners/102/companies?page=1&perPage=2","message":"Format is Authorization: Bearer [token]","backendStatus":401

     

    Or somehow the format is not correct how you give the token to authorization.

This discussion has been closed.