Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum ProjectWise Connector for Microsoft Flow and IFTTT (If This Then That)
    • Sign In

    • Replies 0 replies
    • Subscribers 65 subscribers
    • Views 1734 views
    • Users 0 members are here
    • Microsoft Flow
    • Web Services Gateway
    • IFTTT
    • ProjectWise
    • ProjectWise PowerShell Modules

    ProjectWise Connector for Microsoft Flow and IFTTT (If This Then That)

    Dave Brumbaugh
    Offline Dave Brumbaugh over 5 years ago

    I finally figured out how to create a rich project with Web Services Gateway and set its properties (also environment and workflow…no way to set storage), and create a document and set the environment properties.  This is limited right now to string properties just because the datatypes are not surviving all the transitions.

    Anyway, here’s how to create a Flow which will upload a file from OneDrive to ProjectWise when you create a file in a specified folder in OneDrive (please try this in case I’m missing steps…):

     First, create a flow with two initial OneDrive Actions that looks like this:

      

    Note that I am using OneDrive and not OneDrive for Business (though that will probably work OK).

    Add a new Action.  Type HTTP in the Search box.  Choose it and you should see this selection of actions:

      

    Pick HTTP – HTTP + Swagger

     Enter this value for the Swagger Endpoint URL:

    projectwiseconnector.azurewebsites.net/.../swagger

     Click Next and you should see this:

     

    Pick the “Send destination parameters, token, file URL to ProjectWise” operation and you should see this:

       

    To get a Token use the PowerShell cmdlet Get-PWConnectorToken.  Usage in a script will be like this:

        $encryptedPassword = Read-Host -Prompt "Enter Password:" -AsSecureString

        $token = Get-PWConnectorToken -UserName "user.name" -Password $encryptedPassword

    The Token value will be something like this:

    /YCD6cLJyTaWPCX+S1pb/J1IW74Ci0q8N5gDm82MMr6z+gnyPJ6hhFE78C33qqanMq4PPbbuy0XshfVSPMrUgrT72JYQmsla7Z+T1Imx+lE=

    The filled in form looks something like this.  Obviously, you have to know the names of the Project Properties and the Environment Attributes.  Probably not an issue since this is a static configuration.  Note that I pull WebURL and File name from the Dynamic Content:

      

     Click Save flow.

     Your completed Flow will look similar to this:

     

     Here’s the underlying JSON if you prefer to cut and paste:

     { 

      "Token": "/YCD6cLJyTY2wJvWFNCfCc0MMQ+cdYu73+MmH43ZshdyqyCGEaDwR1JoRdyLrv8R…",

      "WSGURL": "https://decide-pwce-us-ws.bentley.com/ws/",

      "Datasource": "decide-pwce-us.bentley.com:decide-pwce-us-10",

      "Folder": "Upload from One-Drive\Uploads",

      "AppendDateToFolder": true,

      "Environment": "ZachWorksharing",

      "Workflow": "ZachWorksharingWorkflow",

      "ProjectType": "General",

    "ProjectProperties": {

            "PROJECT_Project_Name": "From One-Drive",

        "PROJECT_Project_Number": "Test 01"

      },

      "SourceURL": @{ body('Create_share_link')?['WebUrl']},

      "Title": "Uploaded from One-Drive",

      "Filename": @{ triggerOutputs()['headers']['x-ms-file-name']},

    "EnvironmentAttributes": {

            "ATTRIBUTE1": "Some Value",

        "DocumentNumber": "XXX-YYY-002"

      },

      "MakeUnique": true,

      "Email": "dave.brumbaugh@bentley.com"

    }

    Unfortunately, the form is not available if you try to go back and edit the Flow. For some reason Flow does not recognize the Swagger endpoint the second time around.  Just delete the HTTP Action and add it again. 

    Test by uploading a file to the monitored folder.  What is not so cool is that this is a more of a scheduled task than an immediate trigger.  Seems to run every 15 minutes of so checking for new content.  Anyway, would be interested to know if you can get it to work.

    For “If This Then That” you’ll build a similar applet.  I hooked mine to Google Drive and to Instagram:

    Here’s what it looks like:

     

     The configuration looks like this:

     

     This is the URL (different from Swagger URL):

    projectwiseconnector.azurewebsites.net/.../PostFileToDatasource

    The rest of the configuration is very ugly and looks like this:

     

    It’s basically the same entries from MS Flow form except we use IFTTT “Ingredients” from the Google Drive “Trigger” (“If”).  Unfortunately, no easy form to fill in here.  The JSON ends up looking like this and you can just cut and paste it.

     { "WSGURL": "https://decide-pwce-us-ws.bentley.com/ws/", "Datasource": "decide-pwce-us.bentley.com:decide-pwce-us-10", "Folder":"Google Photos\\Auto Upload", "AppendDateToFolder":true,"Token": "/YCD6cLJyTY2wJvWFNCfCc0MMQ+cdYu73+MmH43ZshdyqyCGEaDwR1JoRdyLrv8R+k+…", "Environment":"ZachWorksharing", "Workflow":"ZachWorksharingWorkflow","ProjectType":"General","ProjectProperties":{ "PROJECT_Project_Name":"IFTTT Test Project","PROJECT_Project_Number":"IFTTT-001"},"Email":"dave.brumbaugh@bentley.com", "SourceURL":"{{FileUrl}}", "Title":"{{Filename}}", "Filename":"{{Filename}}", "EnvironmentAttributes":{ "ATTRIBUTE1":"From IFTTT","DocumentNumber":"IFTTT-001"},"MakeUnique":true}

     Ugly, but you only have to do it once.

     For Instagram:

     

    JSON is like this:

    { "WSGURL": "https://decide-pwce-us-ws.bentley.com/ws/", "Datasource": "decide-pwce-us.bentley.com:decide-pwce-us-10", "Folder":"Instagram Photos\\Auto Upload", "AppendDateToFolder":true,"Token": "/YCD6cLJyTY2wJvWFNCfCc0MMQ+cdYu73+MmH43ZshdyqyCGEaDwR1JoRdyLrv…", "Environment":"ZachWorksharing", "Workflow":"ZachWorksharingWorkflow","ProjectType":"General","ProjectProperties":{ "PROJECT_Project_Name":"IFTTT Test Project Instagram","PROJECT_Project_Number":"IFTTT-001-Instagram"},"Email":"dave.brumbaugh@bentley.com", "SourceURL": "{{Url}}", "Title":"{{Caption}}", "Filename":"{{Caption}}.jpg", "EnvironmentAttributes":{ "ATTRIBUTE1":"From IFTTT","DocumentNumber":"{{CreatedAt}}"},"MakeUnique":true}

    The IFTTT applets are much more like actual triggers, the essentially fire right away when the event happens. 

    Anyway, I'm quite happy with my connector.  Looking forward to adding more features, but I love the fact that it has no dependencies on the Windows Desktop.

    • Sign in to reply
    • Cancel

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies