Asked

How Do I Specify Http Post Headers?

@athena or anybody, how to make http post request to api with headers (accept and content-type)?

var url = "https://api.play.ht/api/v2/tts/stream";;
var postData = `{
  "text": "Hey, this is Jennifer from Play. Please hold on a moment, let me just um pull up your details real quick.",
  "voice": "s3://voice-cloning-zero-shot/d9ff78ba-d016-47f6-b0ef-dd630f59414e/female-cs/manifest.json",
  "output_format": "mp3",
  "speed": 1,
  "sample_rate": 24000,
  "voice_engine": "PlayHT2.0-turbo"
}`;
var timeout = 10000;
var headerNames = ["AUTHORIZATION", "X-USER-ID", "accept", "content-type"];
var headerValues = ["x", "x", "audio/mpeg", "application/json"];
Console.log("sound request");
var sound = Net.hTTPPost(url, postData, timeout, headerNames, headerValues);
Console.log(sound);

it provides error:

> sound request
> Execution Error Line 18 Col 0 - The 'accept' header must be modified using the appropriate property or method.
Parameter name: name


ARC Pro

Upgrade to ARC Pro

Discover the limitless potential of robot programming with Synthiam ARC Pro – where innovation and creativity meet seamlessly.

#1  

*Note: I moved the question to a new thread because it was hijacking another thread.