简体   繁体   中英

Python post request to C#

Below code I need to call in c#, how do we can achieve this, please help me.

import requests #requires "requests" package
import json
response = requests.post('https://scm.commerceinterface.com/api/v3/mark_exported',                       data={'supplier_id':'111111111', 'token':'sample-token', 
      'ci_lineitem_ids':json.dumps([54553919,4553920])}).json()
if response['success'] == True:
   #Successfully marked as exported (only items which are not already marked exported)
   pass
else:
   pass

//I got sollution

C# post request

var client = new RestClient(exportUrl);
            var request = new RestRequest(Method.POST);
            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("content-type", "application/json");
            request.AddParameter("supplier_id", apiSupplierID);
            request.AddParameter("token", apiToken);
            request.AddParameter("ci_lineitem_ids", exportOrders);
            IRestResponse response = client.Execute(request); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM