InvalidEndpoint Exception in ListScheduledQueries call in .NET

35 views Asked by At

I'm using ListScheduledQueries call in my project in .NET: https://docs.aws.amazon.com/timestream/latest/developerguide/API_query_ListScheduledQueries.html

I got the following error message: Failed to discover the endpoint for the request. Requests will not succeed until an endpoint can be retrieved or an endpoint is manually specified.

I read about the Discovery endpoint but still haven't found out how to use it - should I provide the endpoint that DescribeEndpoints returns? and if so, how? because it's not a valid parameter for the API call.

Would appreciate your assistance.

I couldn't understand

1

There are 1 answers

0
rlhagerm On

I do not see an example like this for TimeStream, but Amazon MediaConvert has a similar process and does have an example in the AWS SDK Code Examples library in C#. The main part is that you get the endpoint and set it to the ServiceURL. It does look like TimeStream also has a ServiceURL you can set in a Config object. If you change to the TimeStream client instead, it might work.

    // Load the customer endpoint, if it is known.
    // When you know what your Region-specific endpoint is, set it here, or set it in your settings.local.json file.
    var mediaConvertEndpoint = _configuration["mediaConvertEndpoint"];

    Console.WriteLine("Welcome to the MediaConvert Create Job example.");
    // If you don't have the customer-specific endpoint, request it here.
    if (string.IsNullOrEmpty(mediaConvertEndpoint))
    {
        Console.WriteLine("Getting customer-specific MediaConvert endpoint.");
        AmazonMediaConvertClient client = new AmazonMediaConvertClient();
        DescribeEndpointsRequest describeRequest = new DescribeEndpointsRequest();
        DescribeEndpointsResponse describeResponse = await client.DescribeEndpointsAsync(describeRequest);
        mediaConvertEndpoint = describeResponse.Endpoints[0].Url;
    }
    Console.WriteLine(new string('-', 80));
    Console.WriteLine($"Using endpoint {mediaConvertEndpoint}.");
    Console.WriteLine(new string('-', 80));
    // Because you have a service URL for MediaConvert, you don't
    // need to set RegionEndpoint. If you do, the ServiceURL will
    // be overwritten.
    AmazonMediaConvertConfig mcConfig = new AmazonMediaConvertConfig
    {
        ServiceURL = mediaConvertEndpoint,
    };

    AmazonMediaConvertClient mcClient = new AmazonMediaConvertClient(mcConfig);