Open richardwfrancis opened 3 years ago
I just ran into a similar issue today with the GetRestApis method. After some troubleshooting I discovered that the amazon apigateway api was returning a Content-Type of 'application/hal+json' when called through Paws, while the awscli was getting 'application/json' returned.
If I set the header 'Accept: application/json' in the request then Paws worked as expected.
e.g.
use Paws::Net::LWPCaller;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->add_handler(
request_prepare => sub{
my($request, $ua, $handler) = @_;
$request->header( 'Accept' => 'application/json' );
}
);
my $caller = Paws::Net::LWPCaller->new( ua => $ua );
my $paws = Paws->new( config => { caller => $caller } );
Searching through botocore I found this line https://github.com/boto/botocore/blob/1.20.21/botocore/handlers.py#L983, where they are explicitly setting the Accept header for apigateway calls.
Update: Changed botocore link to reference a specific tag in case the line numbers change in the future (was referencing the develop branch previously)
Thank you @msven , great detective work.
There may be another way to do it, but adding the following code after creating the ApiGateway service worked for me.
$apigateway->caller()->ua()->default_headers( {'Accept' => 'application/json'} );
This worked in my case because calling $apigateway->caller()->ua()
told me the agent being used was of the class HTTP::Tiny. If other agents are used then there may be other ways to provide the request headers.
Hopefully this will help the Paws developer team to alter the relevant module and include the right request header.
I will have to check but I think in one of my many many patches (not released) I found and fixed that one. I will be getting back to PAWS this month sometime. I just have to do the .42 release then I will get back to squishing reported bugs
Cheers John
Just reporting odd behaviour with ApiGateway::GetApiKeys
The above code returns:
I had expected this to return all available API keys and values (there are 5 already present in the AWS console).
Note that I am able to create new API keys using Paws as expected (i.e. a new one is created in the AWS console) using:
However, GetApiKeys still doesn't return anything.
Also, equivalent Python code using boto3 pulls back all the keys as expected.
Any help would be appreciated.