Hi there.

In a consultation with a customer I verified if I can output files to OneDrive via API, and confirmed that it can be achieved.
Below, I will summarize how to set up the collaboration.

TOC
1: Background to considering the collaboration between OneDrive and Questetra
2: Settings for linking OneDrive and Questetra
  2.1: OAuth settings on the OneDrive (Office 365) side
  2.2: OAuth settings on the Questetra side
  2.3: Settings for invoking OneDrive APIs from Questetra
3: Summary

1: Background to considering the collaboration between OneDrive and Questetra

As an output to online storage Google Drive is equipped on Questetra as the standard function. Also, we provide Add-on XML (which you can import to Questetra) for output to Box or Dropbox. But there is not one for OneDrive yet, so I looked into this.
* Related Manual: M229: Auto Backup to Google Drive
* Related Add-on: Upload to Box
* Related Add-on: Upload to Dropbox

2: Settings for linking OneDrive and Questetra

There is an article I have summarized before regarding collaboration between Office 365 including OneDrive.
* Related Article: How to Cooperate between Office 365 and Cloud Based Workflow
As I describe in that article, concerning authentication, the Questetra side can only support the OAuth2 settings if you use the Authorization Code in Azure AD v2.0 endpoint. If I could not use that method, it would have been a bit troublesome, but in this case it was okay.

Please refer to the following article for details of the OAuth2 settings. In this article, I will describe things specific to cooperation with OneDrive.
Related Article: Settings when Calling REST API of Another Service from Questetra (Questetra to be OAuth2 client)

2.1: OAuth settings on the OneDrive (Office 365) side

Start by adding an app on the “My application” screen.

  • Type anything you want for Application Name
  • Ignore Guided Setup, and click on Create.
  • Make a note of the Application Id.
  • In Application Secrets, select Generate New Password, and make a note of the password.
  • In Platforms, click Add Platform and select Web, then set Questetra’s callback URL as the Redirect URL.
  • In Microsoft Graph Permission – Delegated Permission, click Add and add Files.ReadWrite. And then “Save” at the bottom.

* It seems that you can set various other things here, so compared with other services, it is rather complicated as an OAuth application registration screen, isn’t it?


Reference Article: Microsoft Graph permissions reference

2.2: OAuth settings on the Questetra side

Set up the followings, then get the token.

2.3: Settings for invoking OneDrive APIs from Questetra

Output was accomplished by using a Throwing Message Intermediate Event (HTTP), .
* Related Manual: M225: Auto Sending of HTTP Request with Business data Inserted

  • Network Settings
    • Access URL: https://graph.microsoft.com/v1.0/me/drive/items/{FOLDER ID}:/{FILENAME}:/content
      • If you specify “root” in the folder ID, it is output under the default folder of the authenticated user
      • Assuming practical settings, it is better to embed Data Items into folder IDs and filenames since they are supposed to vary.
    • HTTP Method: PUT (Specify Request Body)
    • “String type data item that will contain error details when an error occurred”: Although it is not mandatory, it is better to specify it so that you can check the error details. Also, it is good to check the data item after this event to determine whether there is an error, and to take action at the time of error.
  • Security / Custom Header: Select “Connect with the OAuth 2.0” and enter the name which you have set above 2.2 in “Setting name”
  • Request Body: St the File-type Data Item that stores the files to be sent to OneDrive in “Data item to send as request body”
  • “Response Settings”: Although it is not mandatory, if you check “Save Response” and specify a String type Data Item, you can confirm the result.

* Reference Article: Upload or replace the contents of a DriveItem

* In the current specification (as of Ver. 11.9.0), in script processing, the number of characters in the HTTP header is limited to 1000 characters (there is no restriction on Trowing Message Intermediate Event (HTTP)). Meanwhile, Microsoft’s tokens exceed 1000 characters in many cases. For this reason we cannot make this process into an Add-on XML at present.

3. Summary

Even though it is not possible to prepare an Add-on XML (to import and to use), hopefully you now understand that you can connect file output to OneDrive with just a few settings.

If you have any question, please feel free to contact us.

%d bloggers like this: