473,378 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to convert this C# code to vb.net

Gobindap
Expand|Select|Wrap|Line Numbers
  1. using (var client = new HttpClient())
  2. {
  3. client.DefaultRequestHeaders.Accept.Clear();
  4. client.DefaultRequestHeaders.Accept.Add(new
  5. MediaTypeWithQualityHeaderValue("application/json"));
  6. BillViewModel p = new BillViewModel
  7. {
  8. username = "Test_CBMS", password = "test@321", seller_pan = "999999999",
  9. buyer_pan = "123456789",
  10. buyer_name="", fiscal_year = "2073.074", invoice_number="102",
  11. invoice_date="2074.07.06", total_sales=1000.01,
  12. taxable_sales_vat=1000.01, vat=130, excisable_amount=0, excise=0,
  13. taxable_sales_hst=0,
  14. hst=0, amount_for_esf=0, esf=0, export_sales=0,
  15. tax_exempted_sales=0,isrealtime=true, datetimeclient = Datetime.now };
  16. client.BaseAddress = new Uri("http://202.166.207.75:9050");
  17. var response = client.PostAsJsonAsync("api/bill", p).Result; if
  18. (response.IsSuccessStatusCode)
  19. {
  20. var result = response.Content.ReadAsStringAsync();
  21. Console.Write(result.Result);
  22. Console.ReadLine();
  23. } else
  24. {
  25. Console.Write("Error");
  26. Console.ReadLine();
  27. }
  28. }
=================================
It tried it as following
Expand|Select|Wrap|Line Numbers
  1. Using client = New HttpClient()
  2.             client.DefaultRequestHeaders.Accept.Clear()
  3.             client.DefaultRequestHeaders.Accept.Add(New MediaTypeWithQualityHeaderValue("application/json"))
  4.             Dim p As BillViewModel = New BillViewModel With {
  5.              .username = "Test_CBMS",
  6.              .password = "test@321",
  7.              .seller_pan = "999999999",
  8.              .buyer_pan = "123456789",
  9.              .buyer_name = "",
  10.              .fiscal_year = "2073.074",
  11.              .invoice_number = "102",
  12.              .invoice_date = "2074.07.06",
  13.              .total_sales = 1000.01,
  14.              .taxable_sales_vat = 1000.01,
  15.              .vat = 130,
  16.              .excisable_amount = 0,
  17.              .excise = 0,
  18.              .taxable_sales_hst = 0,
  19.              .hst = 0,
  20.              .amount_for_esf = 0,
  21.              .esf = 0,
  22.              .export_sales = 0,
  23.              .tax_exempted_sales = 0,
  24.              .isrealtime = True,
  25.              .datetimeClient = DateTime.Now
  26.             }
  27.             client.BaseAddress = New Uri("http://202.166.207.75:9050")
  28.  
  29.             'Dim response = client.PutAsync("api/bill", p).Result
  30.  
  31.             Dim response = client.PostAsJsonAsync("api/bill", p).Result
  32.             If response.IsSuccessStatusCode Then
  33.                 Dim result = response.Content.ReadAsStringAsync()
  34.                 Console.Write(result.Result)
  35.                 Console.ReadLine()
  36.             Else
  37.                 Console.Write("Error")
  38.                 Console.ReadLine()
  39.             End If
  40.         End Using
  41.  
==========================
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
1 2353
Frinavale
9,735 Expert Mod 8TB
According to the documentation on the MSDN Library for the PostAsJsonAsync method...it is only available if you are referencing the System.Net.Http namespace in the System.Net.Http.Formatting assembly.

Make sure you have referenced everything appropriately.
Mar 19 '18 #2

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

Similar topics

2
by: Graham Feeley | last post by:
Hi I have data resembling like this Clearing, The Italian Job, The Final Cut, The Manson Family, The I would like some code to convert the data to The Clearing The Italian Job The Final Cut
1
by: Diego | last post by:
Hi, Anyone can help to convert this code to C#? Public Class MonImageConverter Inherits System.Windows.Forms.AxHost Public Sub New() MyBase.New("59EE46BA-677D-4d20-BF10-8D8067CB8B33") 'note...
8
by: Mike | last post by:
is there a tool that will convert cold fusion code to C#? Or anything out there to help in this process? thx
15
by: Tanzim Saqib | last post by:
I've been trying to learn VB.NET. I know VB6. I can not convert the following VB6 code segment to VB.NET In VB 6: ' In a module starts here: Public Declare Function SetTimer Lib "user32"...
3
by: Dushyant | last post by:
Hello everyone, I am working on converting one code from VB to VB.NET. I am stuck at some point, please help me how to convert following code from VB to VB.NET : Dim xImage As...
2
by: shapper | last post by:
Hello, Could someone, please, convert the following code line to VB.NET? bool containsValue = myList.Any(item =item.NameParameter == nameParameterValue); (This is .NET 3.5. I couldn't find...
1
by: shapper | last post by:
Hello, I am having problems in converting the following code line to VB.NET: Control list = MyFun(myControl, delegate(Control ctl) { ctl.ID == "MyControl"; }); Could someone please help me...
4
by: Sam | last post by:
I am new in software development, and need some help. Please help me convert a class written in c# to vb.net. Thanks, Sam
3
mshmyob
by: mshmyob | last post by:
I am new to vb.net and would like to be able to convert the following code to it's own function - either inside the current module or better yet in a seperate class. This code currently runs in...
2
by: royhoja | last post by:
How do i convert the following code into a function? What parameters would be in the function? printingform(???,???) #include <stdio.h> #include <string.h> int main() { int i;
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.