php - HTTP Post with Header Fields and XML data in C# -
i new c# , want post http request 1 specific url along http headers , xml data. having php code don't know how write same in c#. php code bellow.
$url ="https://datasend.getdata.com"; $session= $_request["session"]; $token= $_request["token"]; $xpost ="<envelope> <header> <version>1</version> <reqversion>1</reqversion> <tallyrequest>export</tallyrequest> <type>data</type> <id>tpgetcompanies</id> <sessionid>$session</sessionid> <token>$token</token> </header> <body> <desc> <staticvariables> <svinclude>connected</svinclude> </staticvariables> </desc> </body> </envelope>"; $headers = array(); $headers[] = 'id:tpgetcompanies'; $headers[] = 'source:mazenettech'; $headers[] = 'target: tns'; $headers[] = 'content-type:text/xml;charset=utf-8'; $headers[] = 'accept-encoding:identity'; $ch = curl_init(); curl_setopt($ch, curlopt_verbose, 1); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_httpheader, $headers ); curl_setopt($ch, curlopt_timeout, 40); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_postfields, $xpost); curl_setopt($ch, curlopt_post, 1); $result = curl_exec($ch); echo($result);
if search there many answers on other communities.
and more.
you can add predefined headers custom header using request.headers property.
Comments
Post a Comment