Passing Parameters to a post httpweb request in asp.net for vb net code - asp.net

Hi guys actually I am new to asp.net and had a task to do. I wast to call a api in post method with certain input paramater and in return I get gst address details. The input is as follows:
This is the purpose of this api:
This Service returns GST details (Address,OwnerName,Pincode,etc.)
**Link**=www.mylink.net/gstdata/gst
**method**= post
**input parameters**=> modid,key,gst (All are string types)
I provide gst no and in return gets the address.
Service Output parameters:
**Parameters Possible Values**
**code** 200,400,500
**status** FAILURE/SUCCESS
**error** string
**data** 1.values (map - key=column_name ,value=column_value)
**uniq_id** string
How do I get these values using HttpWebRequest parameter in vb net code? Please help

I would use
Dim WC as new WebClient
Dim HTML as string = WC.downloadstring("http://example.com/GetAdres?of=John")
Now you will have the Actual HTML of your service output. to further process it, we will need a little more information.
It is not clear to me how the service output is actually formatted, for this we need an example in raw HTML. can you please PASTE the actual Source code of the WebPage to me? the real source in source code, do not copy the document itself.
Security note
do not send the pincode... keep it on the server, and send the pincode to the server instead when it needs to be compared.

Related

Encoding a dictionary in URL Encoding

I'm trying to attach a payment source in Stripe. To do so, I want to directly pass payment info. This is documented here. If you read description of source parameter, you'll understand my requirement.I want to attach dictionary of params to source param.
My question is how should I attach the params like object, account_number etc. which are supposed to be a dictionary under source param
PS: I'm trying to hit this api using Postman
I just found out a way of doing it. params are attached in the following format.
Request Type: POST
and to attach a source param with dictionary format, param is source[object], source[account_number] etc.

Querystring in C# web application

I have created web application.I am giving one of web page to client as api.Client can pass parameter to web page like below
Ex: www.domainname.com/Testpage.aspx?name=pinky&city=pune&number=xxxxxxxx
In same page Testpage.aspx,I am accessing/fetching querystring like below.
string s= Request.Querystring["name"];
I am not sure how client can call api.I mean to say from browser or code throught.Whether client use urlencode or not?
from code
www.domainname.com/Testpage.aspx?name=Server.UrlEncode("pinky")&city=Server.UrlEncode("pune")&number=Server.UrlEncode("xxxxxxxx")
will below code work ? or does i need to decode?If client did not use Encode then decode work fine?.I want user querystring value further processing and insert into table.
string s= Request.Querystring["name"];
You need not decode it. If they have entered special characters and not encoded then it will not reach your server-side code at all because it will throw a bad request error. If they have encoded at their end then it will be automatically decoded at your end.
Even If they have not encoded, Your decode will work fine.

Send query string parameter from a non-web application

Ok, I've been bugging with this for too long.
I need to call my website from a rough VB.net app. Then only thing I need is to attach a query string parameter to the calling url, so I can distinguish the pages to be shown to different VB app users.
So I want to click a button and launch that website, giving this parameter.
First I was bugging with adding the system.web libraries. Now I can't use Request/Response.QueryString as well.
I tried getting some example help from this post. but as I said before - I cannot make use of Request.QueryString as I cannot import it.
I am stuck here:
Process.Start("http://localhost:56093/WebSite1?id=")
I need to attach a query string parameter to the url and then open the website with that url.
Can someone just give me a sample code for my problem.
Query parameters are parsed by the web server/http handler off the URL you use to call the page. They consist of key and value pairs that come at the end of the URL. Your code is nearly there. Say you needed to pass through the parameters:
ID = 1234
Page = 2
Display = Portrait
Then you'd turn them into a URL like this:
http://localhost:56093/WebSite1?ID=1234&Page=2&Display=Portrait
Therefore in your code you'd have:
Process.Start("http://localhost:56093/WebSite1?ID=1234&Page=2&Display=Portrait");

Http call parameters SoapUI

How can I Parameterize an http call parameter in soapui to read parameters from a txt file for each iteration.
If needed can the parameters be encoded(url or gzip) before the call was sent?
Any help (pointers/links/code) is greatly appreciated? Thank You
Use groovy script test step to read data from txt file and store the data in TestCase property .
Something like this would work:
String fileContents = new File('/path/to/file').text;
testRunner.testCase.setPropertyValue(property_name, fileContents);
More information about groovy script steps here.
You can access this property as ${#TestCase#property_name} in your requests. Then you can use template parameters for your request url - I've already answered about it here.
If i'm not wrong you are asking about parametrization of URL which you send as HTTP Request for your Rest call. Let me explain you with an example :
Suppose you are looking for a resource and invoking the WebService using the GET method by making use of the ResourceID already present in the DB...Parametrize it as below :
http://${#Project#HOST}:${#Project#PORT}/rest/${#Project#WebApplicationName}/Resource/${#TestCase#ResourceID}
where HOST, PORT, WebApplicationName are the Project Level properties and ResourceID is a Test Case Level property(as it may change with the test cases i.e., dynamic in nature).
This is my approach of parametrization instead of taking it from a local file. Hope this helps!

MVC3 Stripping Query String from my Parameter

I have an MVC3 Action that takes a parameter (a URL) that may have a query string in it. My action signature looks like this:
GetUrl(string url)
I expect to be able to send it urls, and it works every time unless there is a query string in the url. For example, if I navigate to:
MyController/GetUrl/www.google.com
the url parameter comes accross as "www.google.com" -Perfect. However, if I send
MyController/GetUrl/www.google.com/?id=3
the url parameter comes accross as "www.google.com/" How do I get MVC3 to give me the whole URL in that parameter? -Including the query string?
It's simple enough to just URL.Encode the passed in URL on the page but you're opening your self to some possible security problems.
I would suggest you encrypt the url then encode it then pass that as your value, the protects you from having people just passing in anything into your app.
That's because system considers id=3 as its own query string. When you construct the link in the view, you need to use #Url.Encode to convert raw url string to encoded string to be accepted as parameter of the controller.

Resources