Discussions

Ask a Question
Back to All

Message Unathorised - animation API

Dear Team,

I am currently utilizing the trial plan of your services to assess their potential integration into our software. We are particularly interested in your capabilities for providing talks, animations, and live streams. While the talks API functions correctly, we are encountering issues with the animation API and live streaming.

Our initial testing project employs both the animation and talks APIs. We aim to create an idle animation of an avatar that transitions into a talk animation once a user request is processed and the response from our knowledge base is obtained. Despite identical authorization headers, the animation API returns an error, while the talks API works flawlessly. Below is the request and the error received from the animation API:

Request to /api/animations:

json

{  
  "source_url": "<https://hogg.utexas.edu/wp-content/uploads/2019/07/mia.png">,  
  "driver_url": "bank://nostalgia/"  
}

Error:

AxiosError: Request failed with status code 401

...
status: 401,
statusText: 'Unauthorized',
headers: { ... },
data: { message: 'Unauthorized' }


To address CORS policy issues, we implemented a Node.js server as a reverse proxy for animation calls. This server also tunnels requests for talks, which function without issues. The relevant endpoints in our Node.js server are as follows:

Node.js Server:

// Endpoint to create idle animation  
app.post("/api/animations", async (req, res) => {  
  console.log("Request to /api/animations with body:", req.body);  
  try {  
    const response = await axios.post(  
      "<https://api.d-id.com/animations">,  
      req.body,  
      {  
        headers: {  
          "Content-Type": "application/json",  
          Authorization: "Basic xxxxx", // Replace with your actual API key  
        },  
      }  
    );  
    console.log("Response from D-ID API:", response.data);  
    res.json(response.data);  
  } catch (error) {  
    console.error(  
      "Error creating idle animation:",  
      error.response ? error.response.data : error.message  
    );  
    res.status(500).json({ error: error.message });  
  }  
});

// Endpoint to create talk  
app.post("/api/talks", async (req, res) => {  
  console.log("Request to /api/talks with body:", req.body);  
  try {  
    const response = await axios.post("<https://api.d-id.com/talks">, req.body, {  
      headers: {  
        "Content-Type": "application/json",  
        Authorization: "Basic xxxx", // Replace with your actual API key  
      },  
    });  
    console.log("Response from D-ID API:", response.data);  
    res.json(response.data);  
  } catch (error) {  
    console.error(  
      "Error creating talk:",  
      error.response ? error.response.data : error.message  
    );  
    res.status(500).json({ error: error.message });  
  }  
});

Could you please confirm if the "Unauthorized" error is due to the limitations of the trial plan? If so, should we upgrade to a different plan to resolve this issue? Additionally, I have exhausted almost all my trial credits debugging the animation API calls.

I look forward to your guidance.

Best regards,

Just