Flow Variable "apiproduct.operation" returning runtime variable ID instead of Name of the API Product's Operation as expected from the Flow Variables documentation.
Receiving runtime variable ID upon printing the context variable during trace session :
print("\napi-product-operation : ", context.getVariable("apiproduct.operation"));
api-product-operation : com.apigee.flow.Variables@af7a5fa
Solved! Go to Solution.
Update: This is a documentation bug and an internal ticket was created (b/390001753).
The helper variable "apiproduct.operation" is only a standalone variable when the OAuthV2 VerifyAccessToken policy is used. The "apiproduct.operation" is not the name of the product operation, it is the object that holds the resource, methods and attributes properties. It's value is something like: "com.apigee.flow.Variables@403960a5"
When VerifyAPIKey policy is used the variable needs to be prefixed with "verifyapikey.{policy_name}". For example, if I set the following values in a response using templating:
{
"application": "{verifyapikey.VA-Header.developer.app.name}",
"product": "{verifyapikey.VA-Header.apiproduct.name}",
"apiproduct.operation":"{verifyapikey.VA-Header.apiproduct.operation}",
"apiproduct.operation.resource":"{verifyapikey.VA-Header.apiproduct.operation.resource}",
"apiproduct.operation.methods":"{verifyapikey.VA-Header.apiproduct.operation.methods}",
"apiproduct.operation.attributes.operation":"{verifyapikey.VA-Header.apiproduct.operation.attributes.operation}",
"apiproxy": "{apiproxy.name}",
"apiproxyRevision": "{apiproxy.revision}"
}
Then in Debug I see:
In my proxy response I too see:
{
"application": "pingstatus-mint-v1-app-1-test",
"product": "pingstatus-mint-v1-product-basic-test",
"apiproduct.operation": "com.apigee.flow.Variables@b50c0d9",
"apiproduct.operation.resource": "/status",
"apiproduct.operation.methods": "[GET]",
"apiproduct.operation.attributes.operation": "get_status",
"apiproxy": "pingstatus-mint-v1",
"apiproxyRevision": "221"
}
Bottom line "apiproduct.operation" is the object that holds the resource, methods and attributes values when using OAuthV2 VerifyAccessToken or "verifyapikey.{policyname}.apiproduct.operation" is the object when using VerifyAPIKey policy.
Hi @yogesh-techy, thank you for your question. Given the holiday season, there might be a slight delay in replies, but we’ll ensure your query is addressed.
We have upcoming office hours planned for the new year. Keep an eye out for the schedule and register for the sessions that interest you! Lastly, our 2024 summary of Apigee-related articles is now live; take a look here. 📑
Thanks @AlexET, appreciate your acknowledgement with shared links.
Of course it's holiday season and wish you and team the very well spend Christmas and Coming New Year..!! I'll hold on till the team celebrate and return from holidays in full swing. tc.
Hi @yogesh-techy !
While we are wating for some proper answer from the staff for your question:
1. What's your expected value? I mean how and where did you give this input to your ApiProduct configuration?
I don't know any option where I could enter such variable.
2. An alternative solution is
2.1. add the operationName/operationId as a custom attribue (key:value)
2.2 verifyApiKey polic
2.3 query the value of that given attribute
pls check these documentations for further info
https://www.googlecloudcommunity.com/gc/Apigee/How-to-use-custom-attributes-in-Apigee-Edge/m-p/58447
https://cloud.google.com/apigee/docs/api-platform/reference/policies/verify-api-key-policy#elements
Or use mgmt API
https://cloud.google.com/apigee/docs/reference/apis/apigee/rest/v1/organizations.apiproducts.attribu...
Br,
Marcelo
Update: This is a documentation bug and an internal ticket was created (b/390001753).
The helper variable "apiproduct.operation" is only a standalone variable when the OAuthV2 VerifyAccessToken policy is used. The "apiproduct.operation" is not the name of the product operation, it is the object that holds the resource, methods and attributes properties. It's value is something like: "com.apigee.flow.Variables@403960a5"
When VerifyAPIKey policy is used the variable needs to be prefixed with "verifyapikey.{policy_name}". For example, if I set the following values in a response using templating:
{
"application": "{verifyapikey.VA-Header.developer.app.name}",
"product": "{verifyapikey.VA-Header.apiproduct.name}",
"apiproduct.operation":"{verifyapikey.VA-Header.apiproduct.operation}",
"apiproduct.operation.resource":"{verifyapikey.VA-Header.apiproduct.operation.resource}",
"apiproduct.operation.methods":"{verifyapikey.VA-Header.apiproduct.operation.methods}",
"apiproduct.operation.attributes.operation":"{verifyapikey.VA-Header.apiproduct.operation.attributes.operation}",
"apiproxy": "{apiproxy.name}",
"apiproxyRevision": "{apiproxy.revision}"
}
Then in Debug I see:
In my proxy response I too see:
{
"application": "pingstatus-mint-v1-app-1-test",
"product": "pingstatus-mint-v1-product-basic-test",
"apiproduct.operation": "com.apigee.flow.Variables@b50c0d9",
"apiproduct.operation.resource": "/status",
"apiproduct.operation.methods": "[GET]",
"apiproduct.operation.attributes.operation": "get_status",
"apiproxy": "pingstatus-mint-v1",
"apiproxyRevision": "221"
}
Bottom line "apiproduct.operation" is the object that holds the resource, methods and attributes values when using OAuthV2 VerifyAccessToken or "verifyapikey.{policyname}.apiproduct.operation" is the object when using VerifyAPIKey policy.
It seems pretty clear this is a documentation bug. There is no such thing as an "operation name" in the API Product definition. The operation has things like "resource" and "methods". But no "name". It does not exist.