0

Power Automate Integration with Pyramid Analytics

I am currently working on integrating Pyramid Analytics with Microsoft Power Automate/ aka Microsoft Fabric to automate the retrieval of JSON files generated by Pyramid. Specifically, I have configured a subscription in Pyramid to output reports as JSON files. I then set up a General Webhook for the publication, which provides a link to the content. This setup successfully triggers in Power Automate, and I can extract the link from the webhook.

However, I encounter an issue when attempting to have Power Automate access and retrieve the file from the provided link. Despite using my Pyramid login credentials, I am unable to authorize access to the file through Power Automate.

I would appreciate your guidance on the following:

  • Authentication Method: Could you please clarify the authentication mechanism Pyramid employs for accessing files via direct URLs? Understanding this will assist me in configuring the appropriate authentication within Power Automate.
  • Integration Best Practices: Are there recommended practices or specific configurations for integrating Pyramid-generated file links with external automation tools like Power Automate?

For your reference, I typically access Pyramid reports through our partner link. And this may be a root of the problem. 

We utilize these sales data to populate an Excel-based tracker that monitors stock balances between two days. Managers have to have a way to enter data and see results through multiple calculations. So this cannot be done on Pyramid Platform. 

Is there a chance any of you have any experience with pulling data from link to the file send through Webhook, automatically?

Thanks for all help!

2 replies

null
    • or_man
    • 8 days ago
    • Reported - view

    The HTTP request needs to contain the authentication token to be able to download the file from the link received from the publication flow automatically.

    To get an API Authentication token use the Pyramid API:
    https://help.pyramidanalytics.com/Content/Root/developer/reference/APIs/REST%20API/APIs%20and%20SDKs.htm

    These are the different API methods to authenticate the user
    https://help.pyramidanalytics.com/Content/Root/developer/reference/APIs/REST%20API/API3/authentication.htm

    After the token is retrieved the following call need to be used:

    URL: {{received_url_from_webhook}}
    METHOD: GET
    HEADER: name: Cookie
    value: PyramidAuth={{token_from_api}}

    example using curl:

    curl -X GET \
    -H "Cookie: PyramidAuth={{token_from_api}}" \
    "{{received_url_from_webhook}}"

     

      • Lukas_Beres
      • 4 days ago
      • Reported - view

       
      Thanks a million for coming back to me. Unfortunately is looking like API is blocked for me. 
      Im getting error: 500 Server Error
      See example of python code i used to test few different authorisation method's.  
       Response:
       

      python test.py

      [Method 1] JSON-based (userName + password)
      Error: 500 Server Error: Server Error for url: https://pyramid.musgrave.ie/API2/auth/Login

      [Method 2] JSON-based (DOMAIN\userName + password)
      Error: 500 Server Error: Server Error for url: https://pyramid.musgrave.ie/API2/auth/Login

      [Method 3] JSON-based (userName + password + domain field)
      Error: 500 Server Error: Server Error for url: https://pyramid.musgrave.ie/API2/auth/Login

      [Method 4] NTLM-based Auth
      NTLM request error: 500 Server Error: Server Error for url: https://pyramid.musgrave.ie/API2/auth/Login

      [Method 5] Kerberos/SSPI-based Auth (Negotiate)
      Kerberos/SSPI request error: 500 Server Error: Server Error for url: https://pyramid.musgrave.ie/API2/auth/Login

      All methods failed to retrieve a token. Check server logs or confirm your endpoint / credentials.

      Would you agree that this may only mean Musgrave didnt allow for API connections?
      Thanks for your help!
      Lukas Beres

      import requests
      # Optional imports for NTLM or Kerberos/SSPI
      try:
          from requests_ntlm import HttpNtlmAuth
          NTLM_AVAILABLE = True
      except ImportError:
          NTLM_AVAILABLE = False
      try:
          from requests_negotiate_sspi import HttpNegotiateAuth
          KERBEROS_AVAILABLE = True
      except ImportError:
          KERBEROS_AVAILABLE = False
      # ------------------- CONFIG SECTION -------------------
      BASE_URL = "https://pyramid.musgrave.ie"
      # For API 2.0, typical endpoint might be "/API2/auth/Login"
      # For API 3.0, or domain-based, check your docs. Could be "/API3/auth/WindowsLogin", etc.
      AUTH_ENDPOINT = "/API2/auth/Login"
      USERNAME = "lukas.beres"
      PASSWORD = "" # Removed here for sharig code
      DOMAIN = "MUSGRAVE"  # If your environment uses a domain
      # ------------------------------------------------------
      def login_json_simple():
          """
          JSON-based login: just "userName" + "password".
          """
          print("\n[Method 1] JSON-based (userName + password)")
          payload = {
              "userName": USERNAME,
              "password": PASSWORD
          }
          return post_for_token(payload)
      def login_json_domain_in_user():
          """
          JSON-based login: domain\\username in the "userName" field.
          """
          print("\n[Method 2] JSON-based (DOMAIN\\userName + password)")
          payload = {
              "userName": f"{DOMAIN}\\{USERNAME}",
              "password": PASSWORD
          }
          return post_for_token(payload)
      def login_json_separate_domain():
          """
          JSON-based login: "userName", "password", plus separate "domain" field.
          """
          print("\n[Method 3] JSON-based (userName + password + domain field)")
          payload = {
              "userName": USERNAME,
              "password": PASSWORD,
              "domain": DOMAIN
          }
          return post_for_token(payload)
      def login_ntlm():
          """
          Uses NTLM (Windows) auth at HTTP transport layer.
          Requires 'pip install requests-ntlm'.
          """
          if not NTLM_AVAILABLE:
              print("[Method 4] NTLM not available (requests-ntlm not installed). Skipping.")
              return None
          print("\n[Method 4] NTLM-based Auth")
          ntlm_user = f"{DOMAIN}\\{USERNAME}"
          try:
              resp = requests.post(BASE_URL + AUTH_ENDPOINT, auth=HttpNtlmAuth(ntlm_user, PASSWORD))
              resp.raise_for_status()
          except requests.exceptions.RequestException as e:
              print("NTLM request error:", e)
              return None
          return parse_token(resp)
      def login_kerberos():
          """
          Uses Kerberos / SSPI, leveraging your current Windows domain login.
          Requires 'pip install requests-negotiate-sspi'.
          """
          if not KERBEROS_AVAILABLE:
              print("[Method 5] Kerberos/SSPI not available (requests-negotiate-sspi not installed). Skipping.")
              return None
          print("\n[Method 5] Kerberos/SSPI-based Auth (Negotiate)")
          try:
              # This attempts SSO with your current logged-in Windows credentials.
              resp = requests.post(BASE_URL + AUTH_ENDPOINT, auth=HttpNegotiateAuth())
              resp.raise_for_status()
          except requests.exceptions.RequestException as e:
              print("Kerberos/SSPI request error:", e)
              return None
          return parse_token(resp)
      def post_for_token(json_payload):
          """
          Helper function to do a POST with a JSON payload and then parse the 'token'.
          """
          try:
              resp = requests.post(BASE_URL + AUTH_ENDPOINT, json=json_payload)
              resp.raise_for_status()
          except requests.exceptions.RequestException as e:
              print("Error:", e)
              return None
          return parse_token(resp)
      def parse_token(resp):
          """
          Tries to parse the JSON response and extract the 'token' key.
          """
          try:
              data = resp.json()
          except ValueError:
              print("Response not valid JSON. Raw text:", resp.text)
              return None
          token = data.get("token")  # or "Token", "sessionToken", etc. depending on your setup
          if token:
              print("Token found:", token)
              return token
          else:
              print("No 'token' in the JSON response. Full response:", data)
              return None
      def main():
          # Try the different login methods in order.
          methods = [
              login_json_simple,
              login_json_domain_in_user,
              login_json_separate_domain,
              login_ntlm,
              login_kerberos
          ]
      
          for method_func in methods:
              token = method_func()
              if token:
                  print(f"SUCCESS with {method_func.__name__}! Got token:\n{token}")
                  break
          else:
              print("\nAll methods failed to retrieve a token. Check server logs or confirm your endpoint / credentials.")
      if __name__ == "__main__":
          main()
      
      

Content aside

  • Status Answered
  • 4 days agoLast active
  • 2Replies
  • 52Views
  • 3 Following