在Asp.net MVC中获取woocommerce订单

时间:2019-03-27 03:06:58

标签: woocommerce

WooCommerce.NET:0.730,vs2017,.netframework 4.5.1 我想实现获取订单功能。代码下方:

public class MyRestAPI : RestAPI
    {
        public MyRestAPI(string url, string key, string secret, bool authorizedHeader = true,
            Func<string, string> jsonSerializeFilter = null,
            Func<string, string> jsonDeserializeFilter = null,
            Action<HttpWebRequest> requestFilter = null) : base(url, key, secret, authorizedHeader, jsonSerializeFilter, jsonDeserializeFilter, requestFilter)
        {
        }
        public override T DeserializeJSon<T>(string jsonString)
        {
            return JsonConvert.DeserializeObject<T>(jsonString);
        }
        public override string SerializeJSon<T>(T t)
        {
            return JsonConvert.SerializeObject(t);
        }
    }

public async Task<ActionResult> Index(string shopUrl)
        {
            string endPoint = "/wp-json/wc/v2/";

            MyRestAPI rest = new MyRestAPI(shopUrl+endPoint, ConfigurationManager.AppSettings.Get("WooAccessKey"), ConfigurationManager.AppSettings.Get("WooSecretKey"));
            WCObject wc = new WCObject(rest);

            //Get all orders
            var orders = await wc.Order.GetAll();

            return View();
        }

但是显示错误: enter image description here

我不知道为什么。这是最简单的项目。它只会得到订单。没有其他插件和自定义代码。我的代码中是否存在逻辑错误?调试此行并进行下一步时:

var orders = await wc.Order.GetAll(); 

出现错误。

0 个答案:

没有答案