Connectors allow custom applications to interact with Learn365 data using Microsoft Power Apps. In case you need to get additional data that can't be accessed with the help of default LMS365 connectors, you can create and use your own connectors. This article provides steps on creating custom connectors and using them in Power Apps.
Also, it may be helpful if you want to use HttpRequest and HttpRequest_v2 actions of the default LMS365 connector in Power Apps. As those actions can be used without limitations only in Power Automate, creating a custom connector can serve as a workaround for such a case.
NOTE
A Microsoft 365 subscription is not enough to use custom and premium connectors. For this method, you should have a standalone Power App license.
In this article
How to create a custom connector
To create a new connector:
1. Navigate to the Power Apps menu, select Solutions, and choose +New solution to create a new solution. Fill out the field and select Create.
2. Double-click the new solution you have just created. This will enable you to add a connector to it by expanding the drop-down +New menu and navigating to Automation > Custom connector.
See more information about solution concepts in Microsoft's documentation.
3. From the Custom connector, you'll be brought to the connector creation page.
- Fill out the fields in the General section step by step: Add the connector name, upload an icon, and add a description, a scheme, a host, and a base URL.
As we are interested in getting the Learn365 data, we'll use the Learn365 cloud API host.
- Proceed to the Security section. Here, select the Basic authentication type.
- In the next section—Definition—you need to create definitions for your connector. You can add numerous actions or triggers that will result in various responses. In our example, we'll use only one action and this should help us get the Learn365 data from the Courses table.
You can add a request that will be used by this action. To do this, select Import from sample, select the GET method, and specify the request URL. In our case, it will be https://ne-api.365.systems/odata/v2/Courses.
We also add query parameters. We want to use $expand as we plan to expand the Tags and Categories parameters and let's add an ability to use $filters.
The next step is to create a response sample. To do this select Response > +Add default sample. A panel opens where you can provide the response sample body.
But before you start, you will need to get the response sample body by following the steps below:
1. Navigate to api.365.systems
2. Use the GET /odata/v2/Courses endpoint.
3. Expand Tags and Categories, so you would get the response that will create the relevant schema
4. Download the result, insert it in the response sample body field, and select the Import button. The schema should be automatically created and added to the connector code.
In case of a successful result, you will see that many parameters were added to the response body, and a "Validation succeeded" message will be displayed.
The Code (Preview) section is optional.
NOTE
You can also use the Swagger Editor for making changes and debugging.
Find more information in Microsoft's documentation on how to create a custom connector from scratch.
When ready with step 1 to 3(4), save all changes, create the connector, and proceed to test it. If everything is correct, you should get a 200 response code.
How to use a custom connector in Power Apps
The next step is to create a simple app that will use the data obtained with the help of our custom connector. To do this follow the steps below:
1. Navigate to Power Apps and select +Create from the side menu, then choose Blank app > Blank canvas app. Specify the name and confirm with Create.
2. Search for your new connector in the Data menu and connect to it.
3. Navigate to the Insert menu and add an element to visualize the data.
4. Using our custom connector, we will make a query to get the course list. We want to have the Tags and Categories tables expanded, also we will filter to only get courses only from a specific catalog. In this wat, the formula should look like this:
Defaulttitle.GetCourses({'$expand':"Tags,Categories", '$filter': "CourseCatalogId eq value"}).value
TIP
'Defaulttitle' here - is the connector title as you could see on previous screenshots. This title be changed in Swagger.
After a few seconds, the data will be loaded. You can add columns to your table. Let's select Title, CourseType, CreatedAt, Categories, and Tags.
The first three columns will be filled out, but the next two, that were expanded, won't have any results except for the [object Object] value in the rows where we supposedly should get category or tag. Also, we can see formula errors for these columns.
However, this can be fixed as we already have expanded these tables in our query. For these columns, we select only one value from the table using the Concat function: Select the column and instead of ThisItem.Categories put Concat(ThisItem.Categories.Name, Name, ", ").
The same applies to ThisItem.Tags.
This will give us the following result:
Comments
Article is closed for comments.