Data Masking Request/Response Content during proxy trace on Apigee Layer - apigee

A SB for a proxy on the Apigee service is returning a string, as opposed to an XML or JSON response. This string may include confidential data, which we would like to mask.
Attempting to set up a DataMaskConfiguration like this:
<MaskDataConfiguration name="default">
<Variables>
<Variable>response.content</Variable>
</Variables>
</MaskDataConfiguration>
Successfully masks the variable response.content in the Variables section of any policies using it during the trace. However, I continue to see the string in the Response Content > Body section of the trace.
Because the response is a string, as opposed to XML or JSON path, I am unable to parse it using either part of the mask data config.
Does anyone know of the variables that I can set int he MaskDataConfiguration to mask the data being presented in the Request and Response Content sections when viewing a policy in the trace? Or, is there another method of doing so outside the scope of MaskDataConfiguration?

There currently is no easy way to do this. You could try masking the variables 'request.content', 'message.content', 'response.content' to see if that works.

Related

BizTalk WCF-WebHttp URI mapping problem with escaped variable

I am trying to use BizTak WCF-WebHttp adapter to send to Service Desk Plus CMDB API using Variable Mapping.
When trying using the browser, it works fine. Service Desk Plus CMDB API requires an URI like (strictly shortened for readability):
http://host.com/api/cmdb/ci?OPERATION_NAME=read&TECHNICIAN_KEY=Mykey&format=XML&INPUT_DATA=<?xml version='1.0'?>
<API>
<name>email#host.com</name>
</API>
I have used the URI http://host.com/api/cmdb/ci and URL Mapping.
<BtsHttpUrlMapping>
<Operation Url="?OPERATION_NAME=read&TECHNICIAN_KEY=MyKey&format=XML&INPUT_DATA=<?xml version=&apos;1.0&apos;?>
<API>
<name>email#host.com</name>
</API>"/>
</BtsHttpUrlMapping>
This works fine, but I need a more dynamic approach. I tried using Variable Mapping, so I replaced the hard coded email address with a variable.
<BtsHttpUrlMapping>
<Operation Url="?OPERATION_NAME=read&TECHNICIAN_KEY=MyKey&format=XML&INPUT_DATA=<?xml version=&apos;1.0&apos;?>
<API>
<name>{email}</name>
</API>"/>
</BtsHttpUrlMapping>
Trying to save the URL Mapping with the variable I get an error.
WCF-WebHttp Transport Properties
Error saving properties.
(System.InvalidOperationException) The UriTemplate
?OPERATION_NAME=read&TECHNICIAN_KEY=MyKey&format=XML&INPUT_DATA=<?xml version='1.0'?><API><name>{email}</name></API>
is not valid; each portion of the query string must be of the form 'name=value', when value cannot be a compound segment. See the documentation for UriTemplate for more details.
If I try a variable that is not within the escaped XML string, like with the key, then it works fine.
<BtsHttpUrlMapping>
<Operation Url="?OPERATION_NAME=read&TECHNICIAN_KEY={key}&format=XML&INPUT_DATA=<?xml version=&apos;1.0&apos;?>
<API>
<value>email#host.com</value>
</API>"/>
</BtsHttpUrlMapping>
My intention is to be able to use a variable within the escaped XML string. If that is not possible; I will have to turn to a dynamic adapter and Create the URI and URL mapping in an orchestration.
Did u understand why it said each portion of the query string must be of the form 'name=value? There are just a few ways to make UriTemplates work.
See how a UriTemplate works here. Here is an example that is valid:
weather/{state}/{city}?forecast={day}
So in your case you should make everything after INPUT_DATA= a variable. Which means the whole escaped XML string you were talking about.

Posting binary buffer payload using Node-RED

I am trying to send a byte array through POST using Node-RED. I can successfully create the buffer using this module and storing it in msg.payload. However I can't figure out how to add it as a parameter in a http request node.
The receiving application requires enclosing quotes. So I use the payload in the following url: localhost:port/path?var=\"{{payload}}\", but it gives
"Error converting http params to args: invalid character '\' looking for beginning of value"
If using it in the request url without quotes: localhost:port/path?var={{payload}} nothing gets through (I can see on the other end).
I am using Protobuf due to the application on the other side, but I've also tried creating a buffer, as described here. However, nothing changes.
POSTs should not have arguments in the URL. The data should all be in the body.
Do you need to make the msg.payload an object with keys matching the arg names.
msg.payload = {
var = [buffer]
}
You will probably have to play around with the content-type header as by default I believe Node-RED will send a JSON body and you probably want application/x-www-form-urlencoded
You can set the headers by adding a msg.headers object

How do I access individual headers from a API request response?

I'm currently creating a test suite for a new API, at the moment I've sent a POST request and it's responding as expected. However, I'm now performing further validation such as checking the status code and also wish to check the Location Header. Problem being, through trial and error I've been unable to access to location header value from the response. Below is some cut down code:
${POST_REQUEST} Replace String ${CLAIM_AVAILABLE_BASE_URL} PLAN_NAME ${VALID_PLAN}
${file_data}= Get Binary File Data/Json/API/GETNaviNetClaimID/valid_aries_claim_local_only.json
${POST_RESPONSE} Post Request APIService ${POST_REQUEST} data=${file_data}
Should Be Equal As Strings ${POST_RESPONSE.status_code} ${HTTP STATUSCODE OK}
I can access the header object using:
${POST_RESPONSE.headers}
But so far I've been unable to pull out just the location header value. Can anyone offer any assistance? I'm using the Requests Library
Seems possible using the below, just replace location with the key you're looking for.
${location_header}= Get From Dictionary ${POST_RESPONSE.headers} location
I don't like this solution though so welcome to anything better!

I have a requirement to make calls to two different end points in a sequence on a given call

I am trying to achieve the functionality where i have to call two different backends / target endpoints that have completely different interface in a sequence. Output of one call becomes input to the second one upon an error condition from the first call.
I would like to know how to implement this. I am new to Apigee so details will help me.
It sounds like you need to do a ServiceCallout in the request flow.
Set up your Target as whatever the second server is that you need to talk to in the normal flow. Then create a policy to callout to your first target:
<ServiceCallout name="myPolicy">
<Request clearPayload="false" variable="myRequest"/>
<Response>myResponse</Response>
<HTTPTargetConnection>
<Properties/>
<URL>http://example.com</URL>
</HTTPTargetConnection>
</ServiceCallout>
Note the Response block puts the headers and payload from the response into an object that you can then extract variables from using "myResponse" as the <Source> in the ExtractVariables policy.
Then you can build a new request for your target with the variables you set in the ExtractVariables by using an AssignMessage policy
Service Callout
http://apigee.com/docs/api-services/content/call-services-or-apis-using-servicecallout
ExtractVariables
http://apigee.com/docs/api-services/content/extract-message-content-using-extractvariables
AssignMessage
http://apigee.com/docs/api-services/content/generate-or-modify-messages-using-assignmessage

Raw, unprocessed URL with ASP.NET Routing

I'm using ASP.NET UrlRoutingModule directly (not through MVC) to map certain routes to their handlers:
RouteTable.Routes.Add(new Route("products/{name}", handler));
Then, at request time, I'm getting the values from each route:
RouteData routeData = HttpContext.Current.Request.RequestContext.RouteData;
routeData.Values.TryGetValue("name", out value);
Everything fine so far, I'm getting the proper values for each route. My problem is encoding: I want to get the raw value of a route data. Example: for the route above, if the requested URL is http://example.com/products/word%2Dword the resulted "name" is "word-word". What I want though is the exact value "word%2Dword".
I know that with ASP.NET I can get the raw unprocessed URL using Request.ServerVariables["HTTP_URL"] but unfortunately I cannot use this here.
Any help would be appreciated.
Thanks
EDIT
My specific problem is that I would like to get more products in a single request using their names. I have for example the following product names: "student,pupil" and "sick,ill" (their name contains a comma). I'm also using a comma to separate names in the request.
I handle the encoding on the client side so the GET request looks like this: http://example.com/products/student%2Cpupil,sick%2Cill (I'm encoding each name separately but I'm not encoding the separator).
On the server side the "name" parameter will be automatically decoded by ASP.NET and the result is: "student,pupil,sick,ill" so now I don't know which is the separator. Request.ServerVariables["HTTP_URL"] returns the URL as I want it ("products/student%2Cpupil,sick%2Cill") so I suppose there has to be a way to get the raw value as a route data.
The "raw value" you're seeing isn't actually the original value, it's what was encoded to make the URL safe for the HTTP Protocol.
http://example.com/products/word%2Dword for instance started out as http://example.com/products/word-word and is turned back into word-word as it comes out of the HTTP transport layer.
If you pass it through Server.URLEncode you will get back the same encoded value (%2D instead of -) - but if you can't use Server variables, are you going to have access to the Server object?

Resources