I have a API call that works with C# but when ported to VB.net is returns a
" Cannot send a content-body with this verb-type."
in the response.content
This same exact call works with C# in with no problem. Is it a UTF encoding issue? I notice the payload in c# is UTF16 encoded but in VB its UTF8.
Can anyone provide a simple request package/example for POST of a REST API that works in VB as the app im chaning is written in VB.NET
What I have tried:
VB.NET
' call resume parser API https://rapidapi.com/pathx-pathx-default/api/skill-extraction/ Dim payload1 As Object = New Dictionary( Of Object , Object ) From { { " operation" , " text_extraction" }, { " text" , " You will be responsible for the development of server-side logic, definition and maintenance of databases, and ensuring high performance and responsiveness to requests from the front-end. Additionally, you will be developing user interface components and implementing them following well-known workflows for whatever languages and frameworks are in use. You will ensure that these components and the overall application are robust and easy to maintain. You are expected to coordinate with your team, working on different layers of the infrastructure. Therefore, a commitment to collaborative problem solving, sophisticated design, and quality products is important." } Dim client = New RestClient( " https://skill-extraction.p.rapidapi.com/skill_extraction" ) Dim request As RestRequest = New RestRequest(Method.Post) request.AddHeader( " content-type" , " application/json" ) request.AddHeader( " X-RapidAPI-Key" , " ##############################" ) request.AddHeader( " X-RapidAPI-Host" , " skill-extraction.p.rapidapi.com" ) ' request.AddParameter("application/json", strOutput, ParameterType.RequestBody) request.AddParameter( " application/json" , payload1, ParameterType.RequestBody) ' Dim result As IRestResponse = client.Execute(request) Dim response As RestResponse = client.Execute(request) ASPxLabel1.Text = response.Content namespace sharptest public partial class jsontest : System.Web.UI.Page protected void Page_Load( object sender, EventArgs e) protected void Button1_Click( object sender, EventArgs e) var client = new RestClient( " https://skill-extraction.p.rapidapi.com/skill_extraction" ); var request = new RestRequest(Method.POST); request.AddHeader( " content-type" , " application/json" ); request.AddHeader( " X-RapidAPI-Key" , " ###########################" ); request.AddHeader( " X-RapidAPI-Host" , " skill-extraction.p.rapidapi.com" ); request.AddParameter( " application/json" , " {\r\n \"operation\": \"text_extraction\",\r\n \"text\": \"Chief Technology Officer Profile Visionary leader with a distinguished history of building\"\r\n}" , ParameterType.RequestBody); RestResponse response = (RestResponse)client.Execute(request); Label1.Text = response.Content.ToString(); Holy cow who would have thought it was that sensitive but apprently by using the integer version for POST it worked!!!
Dim client = New RestClient( " https://skill-extraction.p.rapidapi.com/skill_extraction" ) Dim request As RestRequest = New RestRequest request.Method = 1 request.AddHeader( " content-type" , " application/json" ) request.AddHeader( " X-RapidAPI-Key" , " c92bc820damshdc50cac3ff03c0fp1caee3jsna52493ef14fa" ) request.AddHeader( " X-RapidAPI-Host" , " skill-extraction.p.rapidapi.com" ) ' request.AddParameter("application/json", strOutput, ParameterType.RequestBody) request.AddParameter( " application/json" , payload1, ParameterType.RequestBody) ' Dim result As IRestResponse = client.Execute(request) Dim response As RestResponse = client.Execute(request) ASPxLabel1.Text = response.Content
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •