Views:


Article #: KA-04132
Published: 9th Jan 2026
Last reviewed: 9th Jan 2026
 

How to authenticate while using the PDU API

 
  1. Introduction
  2. Purpose
  3. Requirements
  4. Procedure
  5. Scripted
 

Introduction

While implementing any of the PDU’s API calls, it is necessary to authenticate via a user’s credentials, such user would have to already exist in the PDU’s configuration

Purpose

The purpose of this article is to guide the end-user in how to create a function or a snippet of code to be included in their scripting or application while invoking any API call.

Requirements

  • Applies to any G5 & G6 Panduit PDU (Any firmware version)
  • Enabled RESTapi Access on the PDU
  • cURL is required to be installed (tool used to access web components using command line)
  • jq is not required but it is used in the example (jq is a JSON output processor)
 

Procedure

While the API calls can be used in a script or application the principle is the same, the example depicted on this procedure applies to a script using cURL and jq. The authentication can be in its own function or incorporated directly into the script, both examples are depicted below, feel free to copy and paste their contents into your application.
Standalone function: this function can be externally called by any script, it would need to be invoked by its name get_session within the script
get_session()
{
PDU_IP='192.168.1.1'
URL=https://$PDU_IP/xhrlogin.jsp

USERNAME='admin'
PASSWORD='pduPassword'

SESSION=`curl --silent --insecure --location $URL  \
--header 'Content-Type: application/json; charset=utf-8' \
--data '{"username": "'$USERNAME'", "password": "'$PASSWORD'", "cookie": 0}' | jq -r '.cookie'`
echo "Using session: "$SESSION " On PDU: "$PDU_IP
}

Script: In the script below, the sensors API is being invoked, it can be run by invoking its name: ./get_sensors
#!/usr/bin/ksh
#get_sensors

PDU_IP='192.168.1.1'
USER='admin'
PASSWORD='pduPassword'
API='/redfish/v1/PowerEquipment/RackPDUs/1/Sensors'
URL=https://$PDU_IP$API

curl --silent --insecure -u "$USER:$PASSWORD" -H "Accept: appllication/json" $URL | jq
  
Output of the script below