Skip to content

Why would DescribeLoadBalancers in the REST API return 400 Bad Request?

0

I have successfully used REST APIs for various functions such as DescribeInstances with the ec2 service and DescribeSecurityGroups also with ec2. But the same basic code is failing with DescribeLoadBalancers. There is a back-end service that does the code signing and as near as I can tell the URL and service are correct. Here's my code and the response is "Received a request without a valid service and operation name":

        var provider=c.getEnterprise().getStorageProvider(names[i]);
        var sr=c.createServiceRequest();
        var endpoint="https://elasticloadbalancing."+provider.getRegion()+".amazonaws.com";
        var service="elasticloadbalancing";
        sr.setFormParameter("Action","DescribeLoadBalancers");
        sr.setFormParameter("Version","2015-12-01");
        sr.setAWSProvider(provider, service);
        sr.setIgnoreStatusCodes(true);
        
        var result=sr.submit(endpoint,true,false);
        c.debug(result.getResponseCode()+" "+result.getResponseMessage())
        c.debug(result.readBody());
2 Answers
0
Accepted Answer

It turns out I was doing a couple of things wrong that the error response from AWS was not revealing.

  1. I was doing a POST instead of a GET.
  2. I was sending content type text/xml instead of application/x-www-form-urlencoded After making those changes, it worked.
answered a year ago
0

To troubleshoot this can you please perform following steps:

  1. Check CloudTrail logs and see what request and response you are seeing for this request from the service.
  2. Also try sending a manual API request for "DescribeLoadBalancers" from AWS CLI and see if you are still seeing the issue [1].

This should help you isolate the issue.

Please feel free to share the response here and I can look into it further. (Please make sure to hide sensitive information from the output.)

References:

[1] https://docs.aws.amazon.com/cli/latest/reference/elbv2/describe-load-balancers.html

AWS
answered a year ago
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.