Can't works with API

#!/bin/bash

#
SERVER_IP="10.1.4.200"
API_KEY="apikeysequence"
QUEUE_ID="01"  #extact name of the queque in the configuration

# Whaiting calls
calls=$(curl --silent --location -g "http://$SERVER_IP/api/v2/queue/$QUEUE_ID/calls" --header "app-key: $API_KEY")

# Debug: 
echo "answer API: $calls"

# Waithing calls count
status=$(echo $calls | jq -r '.status')
if [ "$status" == "success" ]; then
    call_count=$(echo $calls | jq -r '.data | length')
    echo "call number: $call_count"
else
    echo "Error API: $(echo $calls | jq -r '.message')"
fi

my erorr is always: {“status”:“error”,“message”:“Invalid Operation”}
Errore API: Invalid Operation

where i’m wrong? the api is correct, the firewall is disabled, it is protected in lan firewall

Are you using a correct api endpoint? You are targetting:

http://$SERVER_IP/api/v2/queue/$QUEUE_ID/calls

But in the api documentation there is no such endpoint

image

I have solved thank you.

This is a forum. Please share your solution with everyone to be able to read in the future.
Thanks.

He was using a wrong non existant api endpoint, so that was never going to work. The fix is to use a correct api endpoint.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.