简体   繁体   English

JSON POST,其内容类型为x-www-form-urlencoded的数组参数

[英]JSON POST with an array parameter with content-type x-www-form-urlencoded

I'm trying to send a JSON request to a third party API. 我正在尝试将JSON请求发送到第三方API。 It seems like the issue is related to sending an array of data (hotels and party). 该问题似乎与发送一系列数据(酒店和聚会)有关。

I'm using RestSharp for the request which looks like this (it's just a test for now, will fix it once the request works). 我正在使用RestSharp来处理看起来像这样的请求(目前仅是测试,一旦请求生效将对其进行修复)。

    var request = new RestRequest(Method.POST);
        request.AddHeader("content-type", "application/x-www-form-urlencoded");

    var client = new RestClient(_Url);
    request.AddParameter("application/x-www-form-urlencoded", "username=test&password=test&hotels=%5B%7B%22partner_id%22%3A%20%2214%22%7D%5D&start_date=2017-08-01&end_date=2017-08-05&party=%5B%7B%22adults%22%3A%202%7D%5D&lang=en_US&currency=EUR&user_country=GR&device_type=d", ParameterType.RequestBody);

    IRestResponse response = client.Execute(request);

When I send the request, I receive the response of "max() [function.max]: Array must contain at least one element". 发送请求时,收到以下响应:“ max()[function.max]:数组必须包含至少一个元素”。

According to the suppliers limited documentation, the format of the request is as follows; 根据供应商有限的文档,请求的格式如下:

 username=test
 &password=test
 &hotels=[{"partner_id":"14"},{"partner_id":"16"}]
 &start_date=2013-07-01
 &end_date=2013-07-03
 &party=[{“adults": 2}]
 &lang=en_US

Any help would be appreciated. 任何帮助,将不胜感激。

供应商文档不正确!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用内容类型application / x-www-form-urlencoded解析从HTTP POST接收的C#中的JSON数据 - Parsing JSON data in C# received from HTTP POST with content-type application/x-www-form-urlencoded 如何在内容类型为x-www-form-urlencoded的C#中发布请求? - How to POST request in c# with content-type being x-www-form-urlencoded? RestSharp在POST上将Content-Type默认为application / x-www-form-urlencoded - RestSharp defaulting Content-Type to application/x-www-form-urlencoded on POST 在WCF ReSTful服务中,POST或PUT请求的Content-Type是否需要为“ application / x-www-form-urlencoded”? - Does the Content-Type of a POST or PUT request need to be 'application/x-www-form-urlencoded' in a WCF ReSTful service? 无法使用 Headers[“Content-Type”] = “application/x-www-form-urlencoded” 在我的 WebClient UploadString 中编码我的 JSON 对象 - Unable to encode my JSON object inside my WebClient UploadString using Headers[“Content-Type”] = “application/x-www-form-urlencoded” 尝试使用Content-Type application / x-www-form-urlencoded来访问API - Trying to reach API using Content-Type application/x-www-form-urlencoded C# HttpClient REST 请求使用 Content-Type: application/x-www-form-urlencoded - C# HttpClient REST request using Content-Type: application/x-www-form-urlencoded 如何以Content-Type的形式返回响应:application / x-www-form-urlencoded; 从WCF服务? - How to return response as Content-Type: application/x-www-form-urlencoded; from WCF service? 使用C#获取Webhooks以JSON形式获取内容类型为x-www-form-urlencode的请求消息 - Getting a request message with a content type x-www-form-urlencoded in a form of JSON using C# for webhooks 如何使用 HTTPclient content type = application/x-www-form-urlencoded POST - How to POST using HTTPclient content type = application/x-www-form-urlencoded
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM