{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
1
Question by Rakesh Jain · Nov 24, 2015 at 12:33 PM · 5.6k Views apigee edgeapigeeapi managementauthentication

How to use custom attributes in Apigee Edge?

I am using Apigee Edge to proxy my API. When connecting to the backend, I want to pass a parameter in the query string. My backend code reads this information from the query parameter.

I want to set this query parameter within the Apigee Edge proxy. The value should be retrieved from a custom attribute, which is set on the API product.

What is the way to achieve my objective using Apigee Edge?

Any help or hint will be appreciated.

Comment
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Close

2 Answers

  • Sort: 
avatar image
4

Answer by Kevin   · Nov 24, 2015 at 12:47 PM

Hi @Rakesh Jain.

You can set your custom attributes on the API Product through the UI. It will be the last section on the create new API Product page. To set a custom attribute when you create an API Product through the Management API, you can include a JSON array with your attributes:

$ curl -H "Content-Type:application/json" -X POST -d \
'{
  "approvalType": "auto", 
  "displayName": "Test API Product",
  "name": "Test Product",
  "proxies": [ "weatherapi" ],
  "environments": [ "test" ],
  "attributes": [
     {
       "name": "customattribute1",
       "value": "value1"
     },
     {
       "name": "customattribute2",
       "value": "value2"
     }
  ]
}' \
https://api.enterprise.apigee.com/v1/o/{org_name}/apiproducts \
-u email:password 

At runtime, when you want to refer to the custom attribute, you need to use a "Verify API Key" policy in your API Proxy. To read the custom attribute in your policies, refer to:

  • Attach a VerifyAPIKey policy to your proxy:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><VerifyAPIKeyasync="false"continueOnError="false"enabled="true"name="Verify-API-Key">	<DisplayName>Verify API Key</DisplayName>	<Properties/>	<APIKeyref="request.queryparam.apikey"/></VerifyAPIKey>
  • Assuming you followed the above steps and use the exact same names (policy name & attribute name), then you should be able to reference your product custom variable as {verifyapikey.Verify-API-Key.apiproduct.customattribute1} in the remainder of your proxy

Or you can read the custom attribute in JavaScript code:

var customattr1 = context.getVariable("verifyapikey.Verify-API-Key.apiproduct.customattribute1");
Comment
Add comment Show 3 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rakesh Jain · Nov 30, 2015 at 10:56 AM 0
Link

@kbouwmeester Thanks, but I want to access custom attribute using JAVA.

avatar image Dino ♦♦ Rakesh Jain   · Jan 07, 2016 at 08:03 PM 0
Link

It works the same from within Java. You only need to use the MessageContext to get the variable. The syntax is very similar to the syntax provided by Kevin for Javascript.

avatar image Erwin Lengkeek · May 31, 2017 at 08:02 AM 0
Link

Thanks bud!

avatar image
0

Answer by Anil Sagar @ Google   · Nov 24, 2015 at 12:40 PM

Dear @Rakesh Jain ,

Welcome to Apigee Community :)

If you would like to have key / value pair specific to API Products & access them runtime based on access token, Apigee Edge has out of the box support for same. You can add API Product custom attributes while creating API product & access same as a flow variable in any of the flow once you add Verify API Key Policy. Find screenshot of same from API Product add screen. You can find more about same here.

If you would like to store simple key, value pair & retrieve same in runtime during API calls, Apigee KVM policy helps you do that. It stores the key / value pair in Apigee Edge store & using same policy you can able to retrieve same in runtime.

You can also use Apigee Cache using Cache related policies to populate request / response as a cache in apigee Edge.


screen-shot-2015-11-24-at-60952-pm.png (25.2 kB)
Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

38 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Content-Length is not getting populated when backend does not send the length in the header. 1 Answer

How did I open this useful modal dialog box in the Apigee Edge "Develop" tab ? 1 Answer

sysadmin does not belong to an organization - orgadmin access failure 0 Answers

OpenAPI2Apigee tool for policies and Shared/Custom Flows 0 Answers

How to parse XML request data using XPath notations in JavaScript 1 Answer

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges