当前位置: 首页>>代码示例>>C#>>正文


C# Request.AddBody方法代码示例

本文整理汇总了C#中Request.AddBody方法的典型用法代码示例。如果您正苦于以下问题:C# Request.AddBody方法的具体用法?C# Request.AddBody怎么用?C# Request.AddBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Request的用法示例。


在下文中一共展示了Request.AddBody方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestAddBody

        public void TestAddBody() {
            Request request = new Request("resource");
            request.AddBody(new Dictionary<string, object>() { { "foo", "bar" } }, "parent");

            RestRequest restRequest = (RestRequest)request;
            CollectionAssert.Contains(restRequest.Parameters.Select(parameter => parameter.ToString()).ToList(), "application/x-www-form-urlencoded=parent%5Bfoo%5D=bar");
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:7,代码来源:RequestTest.cs

示例2: TestAddBodyWithListOfIResource

        public void TestAddBodyWithListOfIResource() {
            Request request = new Request("resource");
            Address address = Address.Retrieve("adr_f1369ed31d114c308f627d8879655bd5");
            request.AddBody(new Dictionary<string, object>() { { "foo", new List<Address>() { address } } }, "parent");

            RestRequest restRequest = (RestRequest)request;
            CollectionAssert.Contains(restRequest.Parameters.Select(parameter => parameter.ToString()).ToList(), "application/x-www-form-urlencoded=parent%5Bfoo%5D%5B0%5D%5Bid%5D=adr_f1369ed31d114c308f627d8879655bd5&parent%5Bfoo%5D%5B0%5D%5Bcreated_at%5D=9%2F15%2F2015%204%3A03%3A23%20PM&parent%5Bfoo%5D%5B0%5D%5Bupdated_at%5D=9%2F15%2F2015%204%3A03%3A23%20PM&parent%5Bfoo%5D%5B0%5D%5Bname%5D=EasyPost&parent%5Bfoo%5D%5B0%5D%5Bstreet1%5D=164%20Townsend%20St&parent%5Bfoo%5D%5B0%5D%5Bstreet2%5D=Unit%201&parent%5Bfoo%5D%5B0%5D%5Bcity%5D=San%20Francisco&parent%5Bfoo%5D%5B0%5D%5Bstate%5D=CA&parent%5Bfoo%5D%5B0%5D%5Bzip%5D=94107&parent%5Bfoo%5D%5B0%5D%5Bcountry%5D=US&parent%5Bfoo%5D%5B0%5D%5Bphone%5D=4154567890&parent%5Bfoo%5D%5B0%5D%5Bresidential%5D=False&parent%5Bfoo%5D%5B0%5D%5Bmode%5D=test");
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:8,代码来源:RequestTest.cs

示例3: Create

        /// <summary>
        /// Create a Batch.
        /// </summary>
        /// <param name="parameters">
        /// Optional dictionary containing parameters to create the batch with. Valid pairs:
        ///   * {"shipments", List<Dictionary<string, object>>} See Shipment.Create for a list of valid keys.
        ///   * {"reference", string}
        /// All invalid keys will be ignored.
        /// </param>
        /// <returns>EasyPost.Batch instance.</returns>
        public static Batch Create(IDictionary<string, object> parameters = null) {
            parameters = parameters ?? new Dictionary<string, object>();

            Request request = new Request("batches", Method.POST);
            request.AddBody(parameters, "batch");

            return request.Execute<Batch>();
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:18,代码来源:Batch.cs

示例4: AddShipments

        /// <summary>
        /// Add shipments to the batch.
        /// </summary>
        /// <param name="shipmentIds">List of shipment ids to be added.</param>
        public void AddShipments(IEnumerable<string> shipmentIds) {
            Request request = new Request("batches/{id}/add_shipments", Method.POST);
            request.AddUrlSegment("id", id);

            List<Dictionary<string, object>> body = shipmentIds.Select(shipmentId => new Dictionary<string, object>() { { "id", shipmentId } }).ToList();
            request.AddBody(body, "shipments");

            this.Merge(request.Execute<Batch>());
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:13,代码来源:Batch.cs

示例5: Create

        public static Tracker Create(string carrier, string trackingCode) {
            Request request = new Request("trackers", RestSharp.Method.POST);
            Dictionary<string, object> parameters = new Dictionary<string, object>() { 
                { "tracking_code", trackingCode }, { "carrier", carrier }
            };

            request.AddBody(parameters, "tracker");

            return request.Execute<Tracker>();
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:10,代码来源:Tracker.cs

示例6: sendCreate

        private static Pickup sendCreate(IDictionary<string, object> parameters) {
            Request request = new Request("pickups", Method.POST);
            request.AddBody(parameters, "pickup");

            return request.Execute<Pickup>();
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:6,代码来源:Pickup.cs

示例7: sendCreate

        private static Address sendCreate(IDictionary<string, object> parameters) {
            Request request = new Request("addresses", Method.POST);
            request.AddBody(parameters, "address");

            return request.Execute<Address>();
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:6,代码来源:Address.cs

示例8: Create

        /// <summary>
        /// Create a CustomsInfo.
        /// </summary>
        /// <param name="parameters">
        /// Dictionary containing parameters to create the customs info with. Valid pairs:
        ///   * {"customs_certify", bool}
        ///   * {"customs_signer", string}
        ///   * {"contents_type", string}
        ///   * {"contents_explanation", string}
        ///   * {"restriction_type", string}
        ///   * {"eel_pfc", string}
        ///   * {"custom_items", Dictionary<string, object>} -- Can contain the key "id" or all keys required to create a CustomsItem.
        /// All invalid keys will be ignored.
        /// </param>
        /// <returns>EasyPost.CustomsInfo instance.</returns>
        public static CustomsInfo Create(IDictionary<string, object> parameters) {
            Request request = new Request("customs_infos", Method.POST);
            request.AddBody(parameters, "customs_info");

            return request.Execute<CustomsInfo>();
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:21,代码来源:CustomsInfo.cs

示例9: Create

        /// <summary>
        /// Create an Item.
        /// </summary>
        /// <param name="parameters">
        /// Dictionary containing parameters to create the item with. Valid pairs:
        ///   * {"name", string}
        ///   * {"description", string}
        ///   * {"reference", string}
        ///   * {"harmonized_code", string}
        ///   * {"country_of_origin", string}
        ///   * {"warehouse_location", string}
        ///   * {"value", double}
        ///   * {"length", double}
        ///   * {"width", double}
        ///   * {"height", double}
        ///   * {"weight", double}
        ///   ADD ANY CUSTOM REFERENCES HERE
        /// All invalid keys will be ignored.
        /// </param>
        /// <returns>EasyPost.Item instance.</returns>
        public static Item Create(IDictionary<string, object> parameters) {
            Request request = new Request("items", Method.POST);
            request.AddBody(parameters, "item");

            return request.Execute<Item>();
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:26,代码来源:Item.cs

示例10: CreateAndVerify

        /// <summary>
        /// Create and verify an Address.
        /// </summary>
        /// <param name="parameters">
        /// Optional dictionary containing parameters to create the address with. Valid pairs:
        ///   * {"name", string}
        ///   * {"company", string}
        ///   * {"stree1", string}
        ///   * {"street2", string}
        ///   * {"city", string}
        ///   * {"state", string}
        ///   * {"zip", string}
        ///   * {"country", string}
        ///   * {"phone", string}
        ///   * {"email", string}
        /// All invalid keys will be ignored.
        /// </param>
        /// <returns>EasyPost.Address instance.</returns>
        public static Address CreateAndVerify(IDictionary<string, object> parameters = null) {
            parameters = parameters ?? new Dictionary<string, object>();

            Request request = new Request("addresses/create_and_verify", Method.POST);
            request.RootElement = "address";
            request.AddBody(parameters, "address");

            return request.Execute<Address>();
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:27,代码来源:Address.cs

示例11: Buy

        /// <summary>
        /// Purchase this pickup.
        /// </summary>
        /// <param name="carrier">The name of the carrier to purchase with.</param>
        /// <param name="service">The name of the service to purchase.</param>
        public void Buy(string carrier, string service) {
            Request request = new Request("pickups/{id}/buy", Method.POST);
            request.AddUrlSegment("id", id);
            request.AddBody(new List<Tuple<string, string>>() {
                new Tuple<string, string>("carrier", carrier),
                new Tuple<string, string>("service", service)
            });

            this.Merge(request.Execute<Pickup>());
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:15,代码来源:Pickup.cs


注:本文中的Request.AddBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。