2016-05-12 9 views
0

、私はは、私はC#に新しいです

curl 'http://shop.nordstrom.com/soajax/storeavailability?postalCode=90067&radius=100' -H 'Origin: http://shop.nordstrom.com' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/49.0.2623.108 Chrome/49.0.2623.108 Safari/537.36' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Referer: http://shop.nordstrom.com/s/cece-by-cynthia-steffe-jackie-cold-shoulder-fit-flare-dress/4261930' --data-binary '{"SameDayDeliveryStoreNumber":0,"styleSkus":[{"StyleId":4261930,"SkuIds":[32882914,32877390,32877377,32882917,32882922,32882926,32877379,32882887,32882891,32877382,32882897,32882902,32882907,32882909]}],"RefreshSameDayDeliveryStore":true}' --compressed 
(perlで私はカールリクエストをMKEするために使用システムコールをdirectyます)私のC#で、次のカールコールを作りたいです

最初に、すべてのパラメータをhttpに変更して、ブラウザで応答を表示することができます

次に、cURL呼び出しをHTTPリクエストに変換できますか?もしそうなら、どうですか?そうでなければ、C#プログラムから上記のcURL呼び出しを行うにはどうしたらよいですか?

+0

[C#でcURLの呼び出しを行う]の可能複製(http://stackoverflow.com/questions/7929013/making-a-curl-call-in-c -シャープ) –

答えて

1

だけHttpWebRequestます

var url = "http://shop.nordstrom.com/soajax/storeavailability?postalCode=90067&radius=100"; 
var request = (HttpWebRequest)WebRequest.Create(url); 
request.Method = WebRequestMethods.Http.Post; 
request.Headers["origin"] = "http://shop.nordstrom.com"; 
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate; 
request.Headers["Accept-Language"] = "en-US,en;q=0.8"; 
request.UserAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/49.0.2623.108 Chrome/49.0.2623.108 Safari/537.36"; 
request.ContentType = "application/json"; 
request.Accept = "application/json"; 
request.Referer = "http://shop.nordstrom.com/s/cece-by-cynthia-steffe-jackie-cold-shoulder-fit-flare-dress/4261930"; 
using (var writer = new StreamWriter(request.GetRequestStream())) 
{ 
    writer.Write("{\"SameDayDeliveryStoreNumber\":0,\"styleSkus\":[{\"StyleId\":4261930,\"SkuIds\":[32882914,32877390,32877377,32882917,32882922,32882926,32877379,32882887,32882891,32877382,32882897,32882902,32882907,32882909]}],\"RefreshSameDayDeliveryStore\":true}"); 
} 

var response = request.GetResponse(); 
using (var reader = new StreamReader(response.GetResponseStream())) 
{ 
    var json = reader.ReadToEnd(); 
    // do stuffs... 
} 
関連する問題