[英]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¤cy=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.