In Apigee, how to get a custom attribute value for a developer using the AccessEntity policy and later in Javascript?

前提是你 提交于 2019-12-05 22:48:14

The EntityIdentifier ref in AccessEntity refers to a variable that identifies the developer to be referenced. There are multiple types of data you can pass in to identify the developer (developeremail, developerid, appid, consumerkey). It is best to include the type of data being used in the EntityIdentifier element. In the example below, the consumer key is stored in the variable client_id:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AccessEntity async="false" continueOnError="false" enabled="true" name="access-developer-attribute">
    <DisplayName>AccessEntity Developer Attribute</DisplayName>
    <EntityIdentifier ref="client_id" type="consumerkey"></EntityIdentifier>
    <EntityType value="developer"></EntityType>
</AccessEntity>

Also, your AssignMessage policy is not correctly retrieving from the AccessEntity.access-developer-attribute variable. You need curly braces around the variable name, otherwise the payload will be the text "AccessEntity.access-developer-attribute".

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="convert-accessentity-xml-to-message-request">
    <DisplayName>Convert AccessEntity Xml To Message Request</DisplayName>
    <Set>
        <Payload type="text/xml">{AccessEntity.access-developer-attribute}</Payload>
    </Set>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="true" transport="http" type="request">accessentity.XYZ-attribute</AssignTo> 
</AssignMessage>

You'll notice also that I've deleted unused fields in the policies. This makes the policies more readable.

Your ExtractVariables and JavaScript should work fine.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!