1

I am trying to use named credentials as one of my endpoints has an underscore but I am running into this error:

FATAL_ERROR System.CalloutException: Invalid characters in hostname

Here is my actual code within the apex class:

        HttpRequest req = new HttpRequest();
        req.setEndpoint('callout:snowflake/api/v2/statements');
        req.setMethod('POST');
        req.setHeader('Authorization', token);
        req.setHeader('X-Snowflake-Authorization-Token-Type', 'KEYPAIR_JWT');
        req.setHeader('Content-Type', 'application/json');
        req.setBody(String.valueOf(JSON.serialize(wrapper)));
        system.debug(req);
        Http http = new Http();
        HttpResponse res = http.send(req);
        System.debug(res);

And here is how the named credential looks like:

label: snowflake

name: snowflake

URL: something_something.snowflakecomputing.com

Any ideas on what I am doing wrong here?

3
  • Hey @identigral I tried that and no luck, I should mention that I am trying this on a scratch org
    – scarecrow
    Apr 11, 2022 at 19:27
  • 2
    You can switch your underscores to hyphens and Snowflake will interpret them on their platform. community.snowflake.com/s/article/…
    – Mark Pond
    Apr 11, 2022 at 21:29
  • That did the trick, thank you!
    – scarecrow
    Apr 11, 2022 at 22:21

0

You must log in to answer this question.

Browse other questions tagged .