# Have problems with PB make API calls

**URL:** <https://forum.ansible.com/t/have-problems-with-pb-make-api-calls/38823>\
**Category:** Ansible Project\
**Created:** [July 8, 2024, 6:57pm UTC](https://forum.ansible.com/t/have-problems-with-pb-make-api-calls/38823 "2024-07-08T18:57:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![williamflow](https://avatars.discourse-cdn.com/v4/letter/w/65b543/32.png) [@williamflow](https://forum.ansible.com/u/williamflow)\
**Post date:** [July 8, 2024, 6:57pm UTC](https://forum.ansible.com/t/have-problems-with-pb-make-api-calls/38823/1 "2024-07-08T18:57:43Z")

</div>

I have a new project I am working on and could use some help. The project is from upper management they want me to write a Playbook that can turn outlets on and off using an APC APDU10450SM with the API

I looked and could not find a collection to use, but I can send API calls to the unit, but unlike what I am used too, that being using a token, you have to send the username and password then the unit will send back a token and that is what is used for executing commands.

I can mock this up in Postman and it works fine, however I have issues when I do this in my Playbook I am in the weeds here would appreciate any help

Cheers

Bill

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [July 8, 2024, 7:46pm UTC](https://forum.ansible.com/t/have-problems-with-pb-make-api-calls/38823/2 "2024-07-08T19:46:03Z")

</div>

I used to have some playbooks that did the same, with the first task  
calling the API and retrieving the token into a registered var, while  
subsequent tasks using that var as input for  
authentication/authorization:

- get\_url: ...  
&nbsp;&nbsp;&nbsp;register: auth\_token

- access\_api:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;token: auth\_token.body/header/etc
