Prompt With List From Variable Populated From Curl Command

Hi,

I have an API call to get issues from Zendesk like this:

I omitted a few fields but the API call returns an array of subjects from those tickets, then I store them into the CASES variable which looks like this:

When I try to prompt the variable, it does not unfold the array, showing the whole variable as an entry. Note that if I manually go over the variables in settings and "remove and add the new line again" it works!

But it fails if use it raw from the curl.

Any thoughts?
Thanks!

Solved it! by changing "save results" to "append results".

Weird!

Hmm...

  • I'd be looking at the output in a text editor that can display invisibles.
  • I'd also try doing some clean-up with search/replace.

I think I spoke too soon. It's back to where it was and I don't understand why.

How can I search and replace the bash output for it to be considered a valid list in the prompt?

What does a variable have to have to render in that way?

All you need are lines separated by linefeeds for the Prompt With List action.

You're using a global variable, so its contents is being retained – and that's probably why appending-to-variable was doing something for you.

I'm surprised it isn't already. But I'd start by taking out CASES=$, the ) after subject', and the echo $CASES line from your shell script -- the output from jq can be saved straight to the KM CASES variable.

As @ccstone says -- CASES is a global variable. That can make it more difficult to see what's going on. Because you suppressed curl error messages with --silent you won't see them, but because the final echo command will always work your action will always be successful and you could be appending an empty string to the data already in CASES.

Thank you both @Nige_S and @ccstone, I was able to fix with both solutions.

I took of the CASES=$( and ) and removed the echo and that, alongside the filtering to Mac Line Endings fixed the thing!

Cheers!

1 Like