Legacy Dev Forum Posts

 View Only

Sign Up

Do a data action with a header in "x-www-form-urlencoded"

  • 1.  Do a data action with a header in "x-www-form-urlencoded"

    Posted 06-05-2025 18:44

    Lucas_POUILLY | 2023-08-25 09:38:48 UTC | #1

    Hello I would like to do the following data action which allows to generate a token.

    Here is my POSTMAN configuration :

    i try this but i don't work :

    ![image

    690x145](upload://ymWDidnHGhpUC0U6GMYv7T2BWyc.png)

    ![image

    690x279](upload://5kI5jJSHzjh8mNk29SmbZUuGEVq.png)

    thank you


    ObsTech | 2023-08-25 16:59:44 UTC | #2

    Are you doing this as part of the "custom auth" data action for a function? or are you trying to make a stand alone data action?

    Usually when I need a token like this I would build a new web service data action, within that in you will set the credentials inside of the configuration to "user defined(Oauth)" this will automatically add a custom auth data action that can be configured to manage the tokens. I should be able to walk you trough the rest of it if that's what your intention is.


    Jason_Mathison | 2023-08-26 02:44:39 UTC | #3

    Assuming that you are implementing an OAuth flow, here is our documentation for this: https://help.mypurecloud.com/articles/how-to-use-the-user-defined-oauth-credential-type/

    --Jason


    Lucas_POUILLY | 2023-08-28 06:37:23 UTC | #4

    Thanks to you 2 for your answers, so I did this then I activated it:

    When I launch I have the following error message although I have defined the scope in the Oauth


    Jason_Mathison | 2023-08-28 13:47:06 UTC | #5

    It looks like you need to include the scope in the requestTemplate. The JSON example on this page includes a a scope and URL encoding:

    https://help.mypurecloud.com/articles/url-form-encoding-for-data-actions/

    --Jason


    Jerome.Saint-Marc | 2023-08-28 13:51:09 UTC | #6

    Hello,

    I assume you are trying to implement First case: Access token request with a shared secret with Azure.

    In this case, I think your custom auth should look like this -> Request Configuration

    {
        "requestUrlTemplate": "${credentials.loginUrl}",
        "requestType": "POST",
        "headers": {
            "Content-Type": "application/x-www-form-urlencoded",
            "Transfer-Encoding": "buffered"
        },
        "requestTemplate": "client_id=${credentials.clientId}&scope=$esc.url(${credentials.scope})&client_secret=${credentials.clientSecret}&grant_type=client_credentials"
    }

    I don't know for sure for the Transfer-Encoding: buffered header but I think it is needed with Azure AD (not supporting chunked).

    Regards,


    Lucas_POUILLY | 2023-08-28 14:55:33 UTC | #7

    Thank you very much it worked!


    system | 2023-09-28 14:38:18 UTC | #8

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 21701