HTTP authentication

Eric Krasner - US 61 Reputation points
2022-04-06T18:51:43.477+00:00

I am trying to do an outbound http call to Freshservice. It requires basic authorization, but it only uses an api key. Below is the code I use when I do this in PowerShell. How do I replicate this in Logic Apps.

PoweShell code:
$APIKey = 'xyz'
$EncodedCredentials = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $APIKey,$null)))
$HTTPHeaders = @{}
$HTTPHeaders.Add('Authorization', ("Basic {0}" -f $EncodedCredentials))
$HTTPHeaders.Add('Content-Type', 'application/json')

This is what I have tried, but I get:
"code": "access_denied",
"message": "You are not authorized to perform this action."

190616-image.png

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,988 questions
{count} votes

Accepted answer
  1. Bruno Lucas 4,421 Reputation points MVP
    2022-04-07T01:38:55.893+00:00

    Hi ,
    This worked for me:
    190741-image.png

    according to their doc, auth is basic (https://developer.freshdesk.com/api/#authentication)

    one good trick to help is importing the curl in postman

    I noticed postman converted into an authorization header that ignores the password, only the work Basic followed by the key. somehow works. the password is made up anyway according to the doc

    190725-image.png

    190761-image.png

    update worked just as well:

    190679-image.png

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. MayankBargali-MSFT 69,991 Reputation points
    2022-04-08T04:37:42.307+00:00

    @Eric Krasner - US Adding more to @Bruno Lucas answer and for the community reference.
    In case someone wants to use the base64 encoding then they can leverage the base64 logic app function.
    You can always refer to this workflow expression functions in Azure Logic Apps document that has the list of supported expression functions.

    191233-api.gif

    **Note: ** The above is only for reference purposes where I have hardcoded the string value, but you can modify it according to your input value or as per your requirement.

    0 comments No comments