Base64 encoding in Apigee Edge Policy

What is the easiest way to perform Base64 encoding in the Apigee strategy? I need to encode the SMS text to be sent programmatically.

I know I can include the code explicitly, but I prefer to use the built-in function (if available).

div>

The most effective way is to create a python script policy, and then use python’s built-in base64 module to build a simple function base64 encoding Or – Decode the parameters.

If you get the sample proxy from here: http://apigee.com/docs/api-services/content/api-proxy-samples, you will be in /simpleProxy A python example was found in /apiproxy/resources/py.

The strategy XML looks like this:

The python code looks like this:

import base64

username = flow.getVariable("request.formparam.client_id")
password = flow.getVariable("request.formparam.client_secret")
< br />base64string = base64.encodestring('%s:%s'% (username, password))[:-1]

flow.setVariable("my.base64.blob", base64string)

Or, if python is not your style, you could do this in javascript using js resources, or even directly in Node.js proxy.

What is the easiest way to perform Base64 encoding in the Apigee strategy? I need to encode the SMS text to be sent programmatically.

I know I can include the code explicitly, but I prefer to use the built-in function (if available).

p>

The most effective way is to create a python script policy, and then use python’s built-in base64 module to build a simple function base64 encoding or – decoding parameters.

If you get a sample proxy from here: http://apigee.com/docs/api-services/content/api-proxy-samples, you will find a python sample in /simpleProxy/apiproxy/resources/py.

The policy XML looks like this:

The python code looks like this:

import base64

username = flow.getVariable("request.formparam.client_id")
password = flow.getVariable("request.formparam.client_secret")

base64string = base64.encodestring('%s :%s'% (username, password))[:-1]

flow.setVariable("my.base64.blob", base64string)

Or, if python is not Your style, you could do this in javascript using js resources, even directly in Node.js proxy.

Leave a Comment

Your email address will not be published.