我需要在C#創建以下PHP POSTC#中使用REST API之後的參數作爲數組
$params = array(
'method' => 'method1',
'params' => array
(
'P1' => FOO,
'P2' => $Bar,
'P3' => $Foo,
)
);
我無法弄清楚如何創建params
陣列。我用WebClient.UploadString()
與json字符串嘗試無濟於事。
如何在C#中構建上述代碼?
我嘗試
using (WebClient client = new WebClient())
{
return client.UploadString(EndPoint, "?method=payment");
}
上述作品,但還需要進一步的參數。
using (WebClient client = new WebClient())
{
return client.UploadString(EndPoint, "?method=foo&P1=bar");
}
P1
無法識別。
我試着UploadValues()
但不能PARAMS存儲在NamedValueCollection
的API是https://secure-test.be2bill.com/front/service/rest/process
你在打什麼API?如果可能,閱讀文檔將會很酷。 –
https://secure-test.be2bill.com/front/service/rest/process –
什麼是downvotes? –