By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

How to convert in C# code to vb.net

Gobindap
P: 24
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new
MediaTypeWithQualityHeaderValue("application/json"));
BillViewModel p = new BillViewModel
{
username = "Test_CBMS", password = "test@321", seller_pan = "999999999",
buyer_pan = "123456789",
buyer_name="", fiscal_year = "2073.074", invoice_number="102",
invoice_date="2074.07.06", total_sales=1000.01,
taxable_sales_vat=1000.01, vat=130, excisable_amount=0, excise=0,
taxable_sales_hst=0,
hst=0, amount_for_esf=0, esf=0, export_sales=0,
tax_exempted_sales=0,isrealtime=true, datetimeclient = Datetime.now };
client.BaseAddress = new Uri("http://202.166.207.75:9050");
var response = client.PostAsJsonAsync("api/bill", p).Result; if
(response.IsSuccessStatusCode)
{
var result = response.Content.ReadAsStringAsync();
Console.Write(result.Result);
Console.ReadLine();
} else
{
Console.Write("Error");
Console.ReadLine();
}
}

================================================== ====
It tried it as following
Using client = New HttpClient()
client.DefaultRequestHeaders.Accept.Clear()
client.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue("application/json"))
Dim p As BillViewModel = New BillViewModel With {
.username = "Test_CBMS",
.password = "test@321",
.seller_pan = "999999999",
.buyer_pan = "123456789",
.buyer_name = "",
.fiscal_year = "2073.074",
.invoice_number = "102",
.invoice_date = "2074.07.06",
.total_sales = 1000.01,
.taxable_sales_vat = 1000.01,
.vat = 130,
.excisable_amount = 0,
.excise = 0,
.taxable_sales_hst = 0,
.hst = 0,
.amount_for_esf = 0,
.esf = 0,
.export_sales = 0,
.tax_exempted_sales = 0,
.isrealtime = True,
.datetimeClient = DateTime.Now
}
client.BaseAddress = New Uri("http://202.166.207.75:9050")

'Dim response = client.PutAsync("api/bill", p).Result

Dim response = client.PostAsJsonAsync("api/bill", p).Result
If response.IsSuccessStatusCode Then
Dim result = response.Content.ReadAsStringAsync()
Console.Write(result.Result)
Console.ReadLine()
Else
Console.Write("Error")
Console.ReadLine()
End If
End Using
==============================================
but is show error in
" Dim response = client.PostAsJsonAsync("api/bill", p).Result"

it says
'PostAsJsonAsync' is not a member of 'System.Net.Http.HttpClient'.


Please please please help me.
Thank you.
Mar 15 '18 #1
Share this Question
Share on Google+
1 Reply


P: 1
Today, there are many online software available for code converter.Check this link http://converter.telerik.com
Mar 15 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.