我在发布到API时遇到问题。发送Httpclient请求中的文本项。我遇到的问题是当我将链接发送到API(requestBody.media_url)时。此链接必须是公共网址。我曾经使用ngrok将文件夹公开为公用文件夹(在wwwroot中)。然后,外部API无法从该文件夹下载文件。 外部api是Rev.Ai
public async Task<ResponseBody> SendAudio()
{
RequestBody requestBody = new RequestBody();
//requestBody.media_url = string.Format("https://xxxx.ngrok.io/Audios/09b69907-b863-4587-be19-fe98301179b8.mp3");
//requestBody.media_url = string.Format("https://drive.google.com/file/d/xxx/view?usp=sharing");
requestBody.media_url = string.Format("https://drive.google.com/file/d/xxx/view?usp=sharing");
requestBody.skip_diarization = "false";
requestBody.skip_punctuation = "false";
requestBody.remove_disfluencies = "false";
requestBody.filter_profanity = "false";
requestBody.speaker_channels_count = null;
requestBody.delete_after_seconds = "2592000";
requestBody.custom_vocabularies = "";
requestBody.metadata = "sample metadata";
var stringContent = new StringContent(JsonConvert.SerializeObject(requestBody), Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Authorization = GetAuthenticationHeader();
var response = await client.PostAsync(urlPath, stringContent);
var temp = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<ResponseBody>(temp);
}