/audio-to-text api not work with axios nodejs #2190

Closed
opened 2026-02-21 17:42:45 -05:00 by yindo · 0 comments
Owner

Originally created by @vkiller on GitHub (Apr 13, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a quesion, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • Pleas do not modify this template :) and fill in all the required fields.

Dify version

0.6.2

Cloud or Self Hosted

Cloud

Steps to reproduce

Acording audio-to-text api,just need fileand userparameters,if use curl

curl -X POST 'https://api.dify.ai/v1/audio-to-text' \
--header 'Authorization: Bearer app-xxxxx' \
--form 'file=@"./33569d89d8aa7451fd1eac201.mp3";type=audio/mp3'

that's work,but when use nodejs api with axios

const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs')

const form = new FormData();
form.append('file', fs.readFileSync('./33569d89d8aa7451fd1eac201.mp3'));

const main = async function() {
  const response = await axios({
    method: "post",
    url: "https://api.dify.ai/v1/audio-to-text",
    data: form,
    headers: { 
      'Authorization': 'Bearer app-xxxxxxxxxxxx',
      "Content-Type": "audio/mp3"
    },
  })
}

main()

then got

      code: 'bad_request_key_error',
      message: 'The browser (or proxy) sent a request that this server could not understand.',
      status: 400

✔️ Expected Behavior

expect the same return as curl

Actual Behavior

Actual

      code: 'bad_request_key_error',
      message: 'The browser (or proxy) sent a request that this server could not understand.',
      status: 400
Originally created by @vkiller on GitHub (Apr 13, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a quesion, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] Pleas do not modify this template :) and fill in all the required fields. ### Dify version 0.6.2 ### Cloud or Self Hosted Cloud ### Steps to reproduce Acording audio-to-text api,just need `file`and `user`parameters,if use curl ``` curl -X POST 'https://api.dify.ai/v1/audio-to-text' \ --header 'Authorization: Bearer app-xxxxx' \ --form 'file=@"./33569d89d8aa7451fd1eac201.mp3";type=audio/mp3' ``` that's work,but when use nodejs api with axios ``` const axios = require('axios'); const FormData = require('form-data'); const fs = require('fs') const form = new FormData(); form.append('file', fs.readFileSync('./33569d89d8aa7451fd1eac201.mp3')); const main = async function() { const response = await axios({ method: "post", url: "https://api.dify.ai/v1/audio-to-text", data: form, headers: { 'Authorization': 'Bearer app-xxxxxxxxxxxx', "Content-Type": "audio/mp3" }, }) } main() ``` then got ``` code: 'bad_request_key_error', message: 'The browser (or proxy) sent a request that this server could not understand.', status: 400 ``` ### ✔️ Expected Behavior expect the same return as curl ### ❌ Actual Behavior Actual ``` code: 'bad_request_key_error', message: 'The browser (or proxy) sent a request that this server could not understand.', status: 400 ```
yindo added the 🐞 bug label 2026-02-21 17:42:45 -05:00
yindo closed this issue 2026-02-21 17:42:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#2190