fix(mulesoft): http content type error (#2916)

This commit is contained in:
qgarnier 2021-06-30 16:16:36 +02:00 committed by GitHub
parent 6916eaf507
commit f6f163c935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -123,7 +123,6 @@ sub settings {
$self->build_options_for_httplib();
$self->{http}->add_header(key => 'Accept', value => 'application/json');
$self->{http}->add_header(key => 'Content-Type', value => $options{content_type});
$self->{http}->add_header(key => 'Authorization', value => 'Bearer ' . $self->{access_token}) if (defined($self->{access_token}));
$self->{http}->add_header(key => 'X-ANYPNT-ENV-ID', value => $self->{environment_id}) if (defined $options{environment_header});
$self->{http}->add_header(key => 'X-ANYPNT-ORG-ID', value => $self->{organization_id}) if (defined $options{organization_header});
@ -140,10 +139,11 @@ sub get_access_token {
my $login = { username => $self->{api_username}, password => $self->{api_password} };
my $post_json = JSON::XS->new->utf8->encode($login);
$self->settings(content_type => 'application/json');
$self->settings();
my $content = $self->{http}->request(
method => 'POST',
header => ['Content-type: application/json'],
query_form_post => $post_json,
url_path => $self->{authent_endpoint}
);
@ -183,7 +183,7 @@ sub request_api {
$self->{access_token} = $self->get_access_token(statefile => $self->{cache});
}
$self->settings(content_type => 'application/x-www-form-urlencoded', environment_header => 1, organization_header => 1);
$self->settings(environment_header => 1, organization_header => 1);
my $content = $self->{http}->request(%options);