{ 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
    • 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 /
  • General /
avatar image
0
Question by Krish · Oct 12, 2018 at 02:19 PM · 211 Views javascriptaccess tokencustom attributesappsapp attributes

How to get all custom attributes of app without knowing the name

I have a requirement to retrieve all the custom attributes of an app and send it to backend.

Now, when I say ALL, i don't know the attribute name. I am wondering how can I achieve it? I believe i need a javascript. Any suggestion will help.

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

1 Answer

  • Sort: 
avatar image
0

Answer by Dino-at-Google   · Oct 12, 2018 at 06:44 PM

Nope, you don't necessarily need JavaScript. You could do it with ExtractVariables.

Supposing you want to transmit all those params as an XML fragment in a header, you could see these results:

$ curl -i -H apikey:$APIKEY https://$ORG-$ENV.apigee.net/appattributes-1/t1
HTTP/1.1 200 OK
Date: Fri, 12 Oct 2018 18:36:59 GMT
Content-Type: application/json
Content-Length: 23
Connection: keep-alive
attrs-in-xml-form: <Attributes><Attribute><Name>DisplayName</Name><Value>AttributesApp</Value></Attribute><Attribute><Name>Notes</Name><Value/></Attribute><Attribute><Name>attr2</Name><Value>value2</Value></Attribute><Attribute><Name>custom-attr-1</Name><Value>value1</Value></Attribute></Attributes>


{
    "status" : "ok"
}

If you're not happy with all the angle brackets, you can use XMLToJSON to get them in JSON form.

$ curl -i -H apikey:$APIKEY https://$ORG-$ENV.apigee.net/appattributes-1/t2
HTTP/1.1 200 OK
Date: Fri, 12 Oct 2018 18:37:02 GMT
Content-Type: application/json
Content-Length: 23
Connection: keep-alive
attrs-json: {"Attribute":[{"Value":"AttributesApp","Name":"DisplayName"},{"Value":{},"Name":"Notes"},{"Value":"value2","Name":"attr2"},{"Value":"value1","Name":"custom-attr-1"}]}


{
    "status" : "ok"
}

If you don't like either of those options, a JavaScript would help you format the attributes into a string that is more appealing. For example, you could transform the name and value members into a regular JS hash. It would look like:

{
 "DisplayName":"AttributesApp",
 "Notes": {}, 
 "attr2":"value2",
 "custom-attr-1":"value1"
}

Please find attached the API Proxy that produces the first two forms. To use it you will need to create an API Product that contains this proxy, and then create an App authorized for the product. Pass the credential (consumer key) for that app as the apikey.

apiproxy-app-attributes.zip


apiproxy-app-attributes.zip (6.4 kB)
Comment
Add comment Show 4 · 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 Krish · Oct 15, 2018 at 03:26 PM 0
Link

Hi @Dino-at-Google

Sorry, my question was not quite clear about my requirement.

In my proxy, after access token validation, I need to get all the custom attributes of the app and send them as header parameters as key-value.

Right now, I have stored one custom attribute with JSON object. then in my Javascript, i loop through the JSON and send the values in the header.

But I don't want JSON object approach, I want to store the values as separate attributes in the app. Also, I don't want javascript.

Wondering is there a way.

avatar image Dino-at-Google ♦♦ Krish   · Oct 15, 2018 at 07:54 PM 1
Link

"I want to shape a header in a particular way, and I want to do it without javascript".

Well, that's not possible. if you constrain the problem that way, no. There is no way.

You can do it if you relax either of those constraints.

You can shape your header in any way you like with JavaScript . Just build on the example I provided above.

Any reason why you don't want to use JavaScript?

avatar image Krish Dino-at-Google ♦♦ · Oct 16, 2018 at 02:55 PM 0
Link

No particular reason, in general, it is suggested to avoid JS policy, isn't it? Maybe I am wrong.

Show more comments

Follow this Question

Answers Answers and Comments

59 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 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

Transfer Custom Attributes From Expired Access Token to New Access Token 3 Answers

MessageLogging Policy or new JavaScript file 1 Answer

How to display the values of an AccessToken in Apigee Trace tool / Request Body? 1 Answer

How do I force Apigee to check for the details of a RefreshToken that is generated from another Product? 0 Answers

Generate access token doesnt seem to work for me.. 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
© 2019 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
  • 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
  • Members
  • Badges