Predix_Logo
  • Categories
    • Questions
    • Predix | Updates
      • Pricing
      • Product
    • Deloitte - Private
    • How-To
    • Accenture-Private
  • Explore
    • Topics
    • Questions
    • Articles
    • Feedback or Feature Requests
  • Sign in
  • Home /
  • Questions /
avatar image
0
Question by gurleen.k@tcs.com · Jun 09, 2017 at 12:18 AM · dashboard-seed

Issue in reading user-provided service credentials in common.lua

I am facing issue in reading credentials from a user-provided service that is binded to my application.

But it is giving error :

" 72 lua entry thread aborted: runtime error: ./common.lua:139: attempt to index field 'userProvidedServiceName' (a nil value)"

Below is the chunk of code which I have written in common.lua :

  function get_app_configs_info()
      local vcap_services = cjson.decode(os.getenv("VCAP_SERVICES"))
        
      local vcapCredentials = vcap_services["*<myUserProvidedServiceName>*"][1].credentials;
      
      return vcapCredentials 
  end
  
  function M.get_app_configs()
      return cjson.encode(get_app_configs_info())
  end


@Greg Stroup , can you please suggest , as I saw in one of the questions in forum,that you were trying something similar with UAA .

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

1 Reply

  • Sort: 
avatar image
1

Answer by Thuan Truong · Jun 09, 2017 at 09:34 AM

The user provided services appear in the VCAP_SERVICES like below, and you should change your code to:

local vcapCredentials = vcap_services["user-provided"][1].credentials;

and get property:

vcapCredentials.licenseKey

"user-provided": [ { "credentials": { "licenseKey": "xyzabcdxxxxxxx" }, "label": "user-provided", "name": "newrelic", "syslog_drain_url": "", "tags": [], "volume_mounts": [] } ]

Comment
Add comment · Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gurleen.k@tcs.com · Jun 11, 2017 at 11:38 PM 0
Share

@Thuan Truong I tried this way also,but still got the same error. Finally, I just returned vcap_services complete json from common.lua and parsed it in my .js file to get the credentials.

Follow this Question

Answers Answers and Comments

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

Setting up the Dashboard Seed project: bower error 4 Answers

"grunt serve" for Dashboard Seed App giving Errors- ServerResponse has no method 'Status' 4 Answers

Dashboard Seed Initial Requirements 3 Answers

Angular JS UI-Router resolve issue with predix - seed. 1 Answer

user login issue with predix seed 6 Answers

GE Monogram
  • Legal
  • Cookies
  • Forum Terms
  • Contact Us
  • Copyright © 2017 General Electric Company. All rights reserved.


Enterprise
Social Q&A

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Submit your feedback or feature request
  • Categories
  • Questions
  • Predix | Updates
    • Pricing
    • Product
  • Deloitte - Private
  • How-To
  • Accenture-Private
  • Explore
  • Topics
  • Questions
  • Articles
  • Feedback or Feature Requests