Workflows Tips #29: Create JSON Objects, Dynamic URLs, and Normalize Inputs

Welcome to another Okta Workflows Tips post. Read all previous tips.

In this post:

  • Use Compose card to create a JSON object
  • Use Compose card to create dynamic links
  • Normalize inputs with To Lower Case/To Upper Case cards

These tips come from Ylan Muller, an avid Okta admin and certified consultant, member of the MacAdmins Slack Community, and the IT Manager at FireHydrant.

Use Compose card to create a JSON object

Use the Text – Compose card to create a JSON object where parts of the JSON are dynamically mapped.

Creating a JSON object with Compose card

The Compose card will return a text representation of the JSON object. Use JSON – Parse card to parse it into an actual JSON object.

Use Compose card to create dynamic links

You can also Text – Compose card to create dynamic URLs.

Creating dynamic URLs with Compose card

Ok, something to be aware of.

It is easy to use the Compose card to create links, it is also easy to accidentally add a space to a link. This can cause an error which is difficult to debug/find. As an alternative, consider using Text – Concatenate card to create dynamic links. The Concatenate card helps prevent intruding space by accident.

Normalize inputs with To Lower Case/To Upper Case cards

Use Text – To Lower Case card to normalize inputs for URLs or when building bots that might interact with APIs that are case sensitive.

Normalizing text with To Lower Case card

Running the above flow, the output of the Compose card will be:

https://host.com/api/v1/vnjmqueihquoziex/groups

And, Text – To Upper Case is used in a similar way:

Normalizing text with To Upper Case card

The output is:

https://host.com/api/v1/DTSLPDLODABWOKDR/groups


Two resources to help you learn more: 

🎥 Short how-to Workflows videos to help you become a better automation builder.

✏️ Read our Workflows How-To Guides based on community member questions.

2 responses to “Workflows Tips #29: Create JSON Objects, Dynamic URLs, and Normalize Inputs”

  1. Rather than using the Text Compose function and a bunch of manual and repetitive typing of JSON syntax (which, as you say, is error prone), why not use the Object Construct function?

    This is quicker, less error prone, allows for documentation on each key/field & the output object can be used as input for Text type inputs, where the stringifying to JSON is done implicitly, negating the need for the separate JSON stringify functions.

    Generally, it’s best to work with objects, only converting to string representation when needed. When you start dealing with nested objects, this more “composable” approach really begins to show its value.

    1. Hi Johnny – thanks for your comment. I agree, using Object – Construct card is better for creating JSON objects.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.