Shippo CreateShipment 在 WinForms 应用程序中返回“基础连接已关闭”

问题描述

我从这里 (https://github.com/goshippo/shippo-csharp-client) 下载了 Shippo API,并在 VS2019 专业版中很好地编译了它。然后我得到了一个测试令牌并开始运行 ShippoExample Programs.cs 项目中的代码。当它尝试创建货件时(下面的最后一行)。我收到一个异常未处理的错误“底层连接已关闭:发送时发生意外错误。”远程主机强行关闭了现有连接。我与我的 IT 人员核对,他确认这绝对是他们这边的,而不是我们这边的某种 IP 块。我已经通过电子邮件联系了他们的支持,但到目前为止没有任何消息。 注意:我也尝试了实时令牌,但出现了同样的错误。 :-p NOTE2:我也尝试关闭防火墙无济于事。同样的错误。 问题已解决:我只是将项目/解决方升级到 4.7.2 框架,一切都很好。

       static void Main(string[] args)
    {
        
        // replace with your Shippo Token. Using a published test token 
        
        APIResource resource = new APIResource("shippo_test_3e588aea3d7fb7f87654342429276e51c14228f9"); 
        //APIResource resource = new APIResource("<Shippo Token>");
        // to address
        Hashtable toAddresstable = new Hashtable();
        toAddresstable.Add("name","Mr. Hippo");
        toAddresstable.Add("company","Shippo");
        toAddresstable.Add("street1","215 Clayton St.");
        toAddresstable.Add("city","San Francisco");
        toAddresstable.Add("state","CA");
        toAddresstable.Add("zip","94117");
        toAddresstable.Add("country","US");
        toAddresstable.Add("phone","+1 555 341 9393");
        toAddresstable.Add("email","support@goshipppo.com");

        // from address
        Hashtable fromAddresstable = new Hashtable();
        fromAddresstable.Add("name","Ms Hippo");
        fromAddresstable.Add("company","San Diego Zoo");
        fromAddresstable.Add("street1","2920 Zoo Drive");
        fromAddresstable.Add("city","San Diego");
        fromAddresstable.Add("state","CA");
        fromAddresstable.Add("zip","92101");
        fromAddresstable.Add("country","US");
        fromAddresstable.Add("email","hippo@goshipppo.com");
        fromAddresstable.Add("phone","+1 619 231 1515");
        fromAddresstable.Add("Metadata","Customer ID 123456");

        // parcel
        Hashtable parcelTable = new Hashtable();
        parcelTable.Add("length","5");
        parcelTable.Add("width","5");
        parcelTable.Add("height","5");
        parcelTable.Add("distance_unit","in");
        parcelTable.Add("weight","2");
        parcelTable.Add("mass_unit","lb");
        List<Hashtable> parcels = new List<Hashtable>();
        parcels.Add(parcelTable);


        // shipment
        Hashtable shipmentTable = new Hashtable();
        shipmentTable.Add("address_to",toAddresstable);
        shipmentTable.Add("address_from",fromAddresstable);
        shipmentTable.Add("parcels",parcels);
        shipmentTable.Add("object_purpose","PURCHASE");
        shipmentTable.Add("async",false);

        // create Shipment object
        Console.WriteLine("Creating Shipment object..");
        // it dies right here. no idea why. 
        Shipment shipment = resource.CreateShipment(shipmentTable);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)