How to check if a Custom attribute is present

I have apps that can have more than one custom attributes of the same kind. This is due to the length/size limitation of how much can be stored in a single custom attribute.

Hence multiple attributes are created with the suffix -1, -2, -3 etc. to store all required information.

These attributes are then added to the target headers and sent to the target endpoint at the time the proxy is executed.

Now, when adding to Target Headers, I don't want to add an attribute that does not exist and I don't know how many attributes are there (this changes between each app). I also don't want to send empty headers with name but no value (this is how i'm handling it now).

Is there a way to check if a certain custom attribute "name" is present before doing something with it?

Prefer not to use Javascript.

0 1 347
1 REPLY 1

One way is to use JavaScript.

Another way is to use AssignMessage and set IgnoreUnresolvedVariables = true. Then refer to the maybe sometimes possibly set variables in a message template.

<AssignMessage name='AM-1'>
  <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
  <Set>
    <Headers>
      <Header name='Krishna'>{customattr1} {customattr2} {customattr3}</Header>
    </Headers>
  </Set>
</AssignMessage>

But in this case the whitespace between the headers will be embedded, whether or not the variables are set.

ps; what's wrong with using JavaScript?