Integration of Plumsail Forms with External API (APIM)

Dear Plumsail Team,

We would like to inquire about a requirement related to Plumsail Forms in SharePoint Online, specifically concerning the retrieval of data from an external system exposed via Azure API Management (APIM).

Could you please advise whether there are any recommended best practices for implementing this type of integration with Plumsail Forms?

Alternatively, we would appreciate clarification on whether this scenario is supported at all when using Plumsail Forms, and whether there are any known limitations that could prevent such an integration.

Additionally, is there a way to obtain a user token in the code, for example using something like:

JavaScript

const tokenProvider = await fd.spfxContext._aadTokenFactory.getTokenProvider();

const token = await tokenProvider.getToken();

Kind regards,
Martin Slabý

Hello @licensing,

Yes, you can communicate with Azure AD / Entra ID secured endpoints.

SPFx context is available in Plumsail Forms, the variable name is spfxContext. And you can retrieve the token with the code:

fd.spfxContext.aadTokenProviderFactory
    .getTokenProvider()
    .then(tokenProvider => {
        // retrieve access token for the enterprise API secured with Azure AD
        // the parameter passed into getToken() is the Application ID or  Application ID URI
        return tokenProvider.getToken('xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
    })
    .then(accessToken => {
        fetch('https://xxxxxx.azurewebsites.net/api/Orders', { //function URL
            headers: {
                Authorization: `Bearer ${accessToken}`,
                accept: 'application/json'
            }
        }).then(async orders => {
            console.log(await orders.json());
        });

Please learn more in Microsoft documentation:

Hello @Margo,

thank you very much for your advice. It has helped us a lot.

Best regards,
Martin

Martin