Discussions
Encountering a `bad request` exception when calling `https://api.heygen.com/v1/streaming.start`.
about 1 month ago by AbdelHamid M Awad
Hi HeyGen Technical Support,
I am encountering a bad request
exception when calling https://api.heygen.com/v1/streaming.start
.
Could you please provide the correct way to execute this call? Below is the sequence I am following in my application:
- Create Token
- New Session
var options = new RestClientOptions("https://api.heygen.com/v1/streaming.new");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("accept", "application/json");
request.AddHeader("x-api-key", "****");
request.AddJsonBody("{\"quality\":\"medium\",\"voice\":{\"rate\":1},\"video_encoding\":\"VP8\",\"disable_idle_timeout\":false}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
var root = JsonSerializer.Deserialize<Root>(response.Content);
var sessionStart = new SessionStart();
sessionStart.session_id = root.data.session_id;
sessionStart.sdp = root.data.sdp;
- Start Session
var json = JsonSerializer.Serialize(sessionStart);
options = new RestClientOptions("https://api.heygen.com/v1/streaming.start");
client = new RestClient(options);
request = new RestRequest("");
request.AddHeader("accept", "application/json");
request.AddHeader("x-api-key", "****");
request.AddJsonBody(json, false);
response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
Thank you for your assistance.
Best regards,