C#C
C#2y ago
Anubhav

Hey guys this is my service file :

public async Task CallThirdPartyApiAsync(string phoneNumber)
{
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.bland.ai/v1/calls");
request.Headers.Add("Authorization", "JAQERTYUIOPSDFGHJKLZXCVBNMRTEIOUYSDFGHJKLZXCVBNMRTEIOUYSDFGHJKLZXCVB");

var content = new StringContent("{\r\n "phone_number": "+91**",\r\n "task": "Say Hello Anubhav How are you",\r\n "voice" : "maya"\r\n}", null, "application/json");
request.Content = content;

var response = await _httpClient.SendAsync(request);
response.EnsureSuccessStatusCode();

var responseContent = await response.Content.ReadAsStringAsync();

// Deserialize the response content into a CallerId object
var callerId = JsonConvert.DeserializeObject<CallerId>(responseContent);

// Save the CallerId object to the database
_context.callerid.Add(callerId);
await _context.SaveChangesAsync();
}

//Here i have to store value of this phone number and Task in string format so that in my swagger i can give any input whatever i want //
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.bland.ai/v1/calls");
request.Headers.Add("Authorization", "JAQERTYUIOPSDFGHJKLZXCVBNMRTEIOUYSDFGHJKLZXCVBNMRTEIOUYSDFGHJKLZXCVB");

var content = new StringContent("{\r\n "phone_number": "+91**",\r\n "task": "Say Hello Anubhav How are you",\r\n "voice" : "maya"\r\n}", null, "application/json");
request.Content = content;
Was this page helpful?