0

Is there a way to get a named credential URL into a variable in apex?

It looks like the named credential path only works for the setEndpoint method.

  • 1
    what you are trying to achieve taking named credential into a variable? – Santanu Boral Mar 14 '18 at 20:04
  • Basically, the callout returns a token. The method needs to return the URL plus that token in it and I don't want to have to store the URL in multiple places – brezotom Mar 14 '18 at 20:13
  • you can store in protected custom settings or custom metadata type – Santanu Boral Mar 14 '18 at 20:21
  • I know that I can, but it seems ridiculous that you would need to store it in 2 places – brezotom Mar 14 '18 at 20:29
4

According to the SOAP API Developer Guide, the NamedCredential object has a field named Endpoint:

Description
The root URL of the endpoint.

So you should be able to do a query like:

SELECT DeveloperName, Endpoint FROM NamedCredential

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.