Generate Unique ID in apigee without using message-id flow variable

Hi All,

@Dino-at-Google

I am using apigee private cloud version, and for the generation of unique id for each api request/ transaction i am using the message-id flow variable. But with this it is giving the router host name details in the id generation and it is not secure to give this apigee generated message-id to the consumers as it contains router host name.

what is the other alternative to generate unique id in apigee. Please give your suggestions.

0 4 1,126
4 REPLIES 4

On cloud, createUUID()

On private cloud, I'd look towards using a javascript policy

can you please share the code for generating unique id using java script policy.

Hi @Manchala

You would do well to use a Javascript policy as Dane has mentioned above as well. This can be a default way of doing it whether on SaaS or on Private Cloud.

You can clone the following git repo into your dev system and build the library. Then upload the uuidv4.min.js and uuid.min.js from the dist folder.

https://github.com/uuidjs/uuid.git


Use this to generate a uuid within a javascript policy where you need it, or populate a flow variable with a javascript policy for use anywhere else.



Hi Prashanth,

Thanks for your inputs. actually we don't have permissions to deploy the libraries to servers.

So i am thinking to use below java script logic. can you validate this logic whether it is recommended approach.

var transactionId = "";

transactionId = generateUUID();

function generateUUID(){

var d = new Date().getTime();

var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {

var r = (d + Math.random()*16)%16 | 0;

d = Math.floor(d/16);

return (c=='x' ? r : (r&0x7|0x8)).toString(16); });

return uuid; }

also similar to this logic if you have used any js code .please share.