c# - WebClient.DownloadString doesn't return value -
i have 1 url special characters |
, &
. url returning json data.
when trying url in browser run , return json data when trying using webclient.downloadstring()
, not work.
example :
using browser :
http://websvr.test.com/abc.aspx?action=b&packetlist=116307638|1355.00 output : [{"column1":106,"column2":"buying successfully."}]
using webclient.downloadstring():
using (webclient wc = new webclient()) { var json = wc.downloadstring("http://websvr.test.com/abc.aspx?action=b&packetlist=116307638|1355.00"); } output : [{"column1":-107,"column2":"invalid parametrer required-(refno|jbprice)!"}]
you should encode packetlist
parameter in url, because includes pipe character, must encoded %7c
. browsers automatically encode necessary characters in url, should encode in code manually.
var json = wc.downloadstring("http://websvr.test.com/abc.aspx?action=b&packetlist=" + system.web.httputility.urlencode("116307638|1355.00");
Comments
Post a Comment