Forum Discussion

TimBurns's avatar
TimBurns
New Contributor III
6 years ago
Solved

Getting the Status from a REST call

Hi Folks, I’m having trouble getting a proper handling from Snaplogic on a REST call. So the rest call will return on success: “entity”: { “MessageId”:“0101017165ec422f-dfa2bb38-faac-4c48-b...
  • tstack's avatar
    6 years ago

    Another option is to use the matches operator that can check a value against a pattern. The nice thing about this approach is that the pattern looks roughly like the value being matched and the type of the value is implicitly checked. So, an error won’t be raised if the value has an unexpected type.

    For your first example:

    The object pattern, { MessageId }, would only match objects that contain the property MessageId. The full expression would look like this:

    $entity matches { MessageId }
    

    For the second example:

    A string pattern that uses the ... wildcard can check for a value with a prefix. The full expression would look like:

    $entity matches "ERROR:"...
    

    (Unfortunately, while there is documentation for the match operator, the documentation for matches seems to be missing at the moment. We’ll get that fixed)