API为什么用响应代码400响应?

我试图制作一个将文本和说话者ID发送到API的应用程序,该应用程序将文本转换为语音并将其发送回去。

我的问题是API响应代码为400。URL是正确的。请求方法正确。

(You can take a look at the API and find more info here)

我还将在下面包含我的代码:

import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;
import org.json.simple.JSONObject;
import java.io.IOException;

class Variables {
    String tekst;
    int speakerID = 7;

}

public class Neurokone {

    public void ConnectToAPIAndSendRequest() throws IOException {
        Variables v = new Variables();

        //Establishes a connection w/ the API.
        URL url = new URL("https://neurokone.cloud.ut.ee/api/v1.0/synthesize");
        HttpURLConnection con = (HttpURLConnection)url.openConnection();
        con.setDoOutput(true);
        con.setDoInput(true);
        con.setRequestMethod("POST");
        con.setRequestProperty("Content-type", "application/json; utf-8");
        con.setRequestProperty("Accept", "audio/wav");

        //This is self explanatory.
        JSONObject jb = new JSONObject();
            jb.put("text:", v.tekst);
            jb.put("speaker_id:", v.speakerID);

            //Sends the request.
            try(OutputStream os = con.getOutputStream()) {
                byte[] input = jb.toString().getBytes(StandardCharsets.UTF_8);
                os.write(input, 0, input.length);
            }


            try {
                //Generate a name for the response file based on user input
                String fileName = v.speakerID + "--" + v.tekst.substring(0,10);
                //Download response file
                ReadableByteChannel rbc = Channels.newChannel(con.getInputStream());
                FileOutputStream fos = new FileOutputStream(fileName);
                FileChannel fc = fos.getChannel();

                fc.transferFrom(rbc, 0, Long.MAX_VALUE);
            } catch (NullPointerException e) {
                System.out.println("Sinu koodis on viga: " + e);
            }
    }

    public static void main(String[] args) throws IOException {
        Variables variables = new Variables();
        Scanner skanner = new Scanner(System.in);

        //Here i am asking user to choose speaker voice and insert text to be sent to the API.
        System.out.print("Sisesta häälekood (7 - 10): ");
        variables.speakerID = skanner.nextInt();
        System.out.print("Sisesta sünteesitav tekst: ");
        variables.tekst = skanner.nextLine();
        variables.tekst = skanner.nextLine();
        skanner.close();

        new Neurokone().ConnectToAPIAndSendRequest();

    }


}

我仍在学习,因此也欢迎其他任何提示