Retrieving Developer Applications List via AccessEntity

I have an `AccessEntity` policy that retrieves developer information. I would like to make the collection of developer applications available in a Javascript policy as an array.

In the past, I have been able to make a single value available in the JS policy (e.g. a custom attribute, email address, etc.). But I can't figure out how to make it so that this:

<Developer>
    <Apps>
        <App>dev-application-1</App>
        <App>dev-application-2</App>
        <App>dev-application-3</App>

Becomes available in the JS policy as:

["dev-application-1", "dev-application-2", "dev-application-3"]

Here is the relevant bit from my `ExtractVariables` policy:

<Variable name="apps" type="string">
  <XPath>/Developer/Apps</XPath>
</Variable>

The ExtractPolicy says there's a "nodeset" variable type, but that triggered a Java Class exception in the proxy when I ran it.

Solved Solved
0 1 260
1 ACCEPTED SOLUTION

No XPath expression seemed to work as I would expect. It looks like the only real way is to access the XML string directly and then parse it yourself, which kind of stinks. Credit to this answer for pointing out what's available as a context variable after `AccessEntity` has executed.

var xmlStr = context.getVariable('AccessEntity.ChildNodes.Load-Developer-Entity.Developer.Apps');

As a side note: It's odd that `AcceessEntity` only returns XML formatted values and not JSON.

View solution in original post

1 REPLY 1

No XPath expression seemed to work as I would expect. It looks like the only real way is to access the XML string directly and then parse it yourself, which kind of stinks. Credit to this answer for pointing out what's available as a context variable after `AccessEntity` has executed.

var xmlStr = context.getVariable('AccessEntity.ChildNodes.Load-Developer-Entity.Developer.Apps');

As a side note: It's odd that `AcceessEntity` only returns XML formatted values and not JSON.