fix cisco fmc (#2366)

This commit is contained in:
qgarnier 2020-11-23 13:27:34 +01:00 committed by GitHub
parent 0510d0ee6d
commit 453c67734c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 3 deletions

View File

@ -127,8 +127,8 @@ sub settings {
my ($self, %options) = @_;
$self->build_options_for_httplib();
$self->{http}->add_header(key => 'Content-Type', value => 'application/json;charset=UTF-8');
$self->{http}->add_header(key => 'Accept', value => 'application/json;charset=UTF-8');
$self->{http}->add_header(key => 'Content-Type', value => 'application/json');
$self->{http}->add_header(key => 'Accept', value => 'application/json');
$self->{http}->set_options(%{$self->{option_results}});
}
@ -164,6 +164,7 @@ sub authenticate {
if ($has_cache_file == 0 || !defined($session_token)) {
$self->{http}->request(
method => 'POST',
url_path => '/api/fmc_platform/v1/auth/generatetoken',
credentials => 1,
basic => 1,
@ -173,7 +174,7 @@ sub authenticate {
unknown_status => '',
critical_status => ''
);
if ($self->{http}->get_code() != 200) {
if ($self->{http}->get_code() < 200 || $self->{http}->get_code() >= 300) {
$self->{output}->add_option_msg(short_msg => "login error [code: '" . $self->{http}->get_code() . "'] [message: '" . $self->{http}->get_message() . "']");
$self->{output}->option_exit();
}