function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Baylor PeakBaylor Peak 

Help with custom setting to store URL please?

Hello all,

I am storing my enpoint for a REST callout inside a custom setting called MyCustomSettings with Name of 'default'. One of the fields inside the custom setting is a type URL field called 'endpoint' with '' for the value.

In my code, I have:

MyCustomSettings__c myCS1=MyCustomSettings__c.getValues('default');
        string endpoint=myCS1.endpoint__c;

When I test my code I am getting this error:

System.NullPointerException: Argument 1 cannot be null

What am I missing please?:)


ANUTEJANUTEJ (Salesforce Developers) 
Hi Baylor,

Have you tried checking if it working fine if you directly give the url?

Also, can you once have a look at the below code which I think might be a similar implementation: []

In case if this came in handy can you close the thread and please mark this as the best answer so that it can be used by others in the future and also helps in keeping our community clean.

Baylor PeakBaylor Peak
Could you please tell me how this works with a List Custom Setting? Your example is for a hierarchy. What I am asking is first in the Custom Setting under setup, do I need to make this a type URL field? Also how do I format my URL inside the value, do I just put Or do I put ‘’ inside quotes?
ANUTEJANUTEJ (Salesforce Developers) 
I tried a similar scenario but I was not able to find URL field in my custom settings under setup however I tried to send a request to the end point via code and I put this in the code [ request.setEndpoint('');  ]

I followed article to get to know about setting the endpoint in the code.