Data Masking not working with Namespace and prefix

I was testing the Data masking functionality using the prefix and namespace as suggested in APIGEE docs but its not working as expected.

https://docs.apigee.com/api-platform/security/data-masking

There is small correction also required with the closing of XPathsRequest in APIGEE doc.

<MaskDataConfiguration><Namespaces><Namespaceprefix="myco">http://example.com</Namespace></Namespaces><XPathsRequest><XPathRequest>/myco:employee/myco:name</XPathRequest><XPathsRequest></MaskDataConfiguration>

Solved Solved
0 5 160
1 ACCEPTED SOLUTION

Your mask configuration is expecting the employee tag belongs to the myco namespace

Using default namespace as follows, it will be in that namespace

<employee xmlns="http://example.com">
  <name>xyz</name>
  <age>50</age>
</employee>

where as in your payload you need to add the namespace to the employee tag too - the closing tag had it, but it doesn't match the opening tag.

The Apigee doc example for this should be updated to match as follows

<myco:employee xmlns:myco="http://example.com">
    <myco:name>xyz</myco:name>
    <myco:age>50</myco:age>
</myco:employee>

View solution in original post

5 REPLIES 5

Do you have any more information on how it's not working? Does your payload use namespaces?

I have used the same Mask configuration and request structure which is present in APIGEE docs for namespace and prefix example - https://docs.apigee.com/api-platform/security/data-masking.

You can use the below mask configuration

<MaskDataConfiguration> <Namespaces> <Namespace prefix="myco">http://example.com</Namespace> </Namespaces> <XPathsRequest> <XPathRequest>/myco:employee/myco:name</XPathRequest> <XPathRequest>/myco:employee/myco:age</XPathRequest> </XPathsRequest> </MaskDataConfiguration>

And below request messgae to try

<employee xmlns:myco="http://example.com"> <myco:name>xyz</myco:name> <myco:age>50</myco:age> </myco:employee>

There seems to be an issue with your messages coming through? Try highlighting the XML tags and selecting the code option before submitting

<this is an example>

Request Message ------------

<employee xmlns:myco="http://example.com">
    <myco:name>xyz</myco:name>
    <myco:age>50</myco:age>
</myco:employee>

MASK Configuration ------------------

<MaskDataConfiguration>
    <Namespaces>
        <Namespace prefix="myco">http://example.com</Namespace>
    </Namespaces>
    <XPathsRequest>
        <XPathRequest>/myco:employee/myco:name</XPathRequest>
        <XPathRequest>/myco:employee/myco:age</XPathRequest>
    </XPathsRequest>
</MaskDataConfiguration>


Your mask configuration is expecting the employee tag belongs to the myco namespace

Using default namespace as follows, it will be in that namespace

<employee xmlns="http://example.com">
  <name>xyz</name>
  <age>50</age>
</employee>

where as in your payload you need to add the namespace to the employee tag too - the closing tag had it, but it doesn't match the opening tag.

The Apigee doc example for this should be updated to match as follows

<myco:employee xmlns:myco="http://example.com">
    <myco:name>xyz</myco:name>
    <myco:age>50</myco:age>
</myco:employee>