¿Es posible enviar una matriz con la extensión Postman Chrome?
He estado usando Postman Chrome extensión para probar mi API y me gustaría enviar una matriz de IDs a través de post. ¿Hay alguna manera de enviar algo listar esto como un parámetro en Postman?
{
user_ids: ["1234", "5678"]
}
15 answers
Necesitas sufijar el nombre de tu variable con []
así:
Si eso no funciona, intente no poner los índices entre paréntesis:
my_array[] value1
my_array[] value2
Nota:
Si está utilizando la aplicación empaquetada postman , puede enviar una matriz seleccionando
raw
/json
(en lugar deform-data
). Además, asegúrese de establecerContent-Type
comoapplication/json
en la pestañaHeaders
. Aquí hay un ejemplo para datos en bruto{"user_ids": ["123" "233"]}
, ¡no olvide las comillas!Si está utilizando el cliente REST postman tiene que usar el método que describí anteriormente porque pasar datos como raw (json) no funcionará. Hay un error en el cliente REST de postman (Al menos obtengo el error cuando uso
0.8.4.6
).
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-07-09 01:29:21
Para mí no trabajar con array[0], array1, .. o array[], array[], ... . Funciona de forma más sencilla:
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-09-17 21:03:38
Aquí está mi solución:
Use form-data y edite como se muestra a continuación:
Key Value
box[] a
box[n1] b
box[n2][] c
box[n2][] d
Y obtendrás una matriz como esta:
{"box":{"0":"a","n1":"b","n2":["c","d"]}}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-03 03:09:50
También tuve ese problema, y lo resolví haciendo lo siguiente:
1-Ir a la configuración del encabezado de la solicitud y agregar lo siguiente:
Accept : application/json, text/plain, */*
Content-Type : application/json;charset=UTF-8
2-Para enviar el array json, me pongo en formato json crudo y establezco el array:
["bbbbbbbbbb","aaaaaaaaaa","987654321","123456789"]
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-12-29 09:17:38
Como lo mencionó @pinouchon, puede pasarlo con la ayuda de array index
my_array[0] value
my_array[1] value
In addition to this, to pass list of hashes, you can follow something like:
my_array[0][key1] value1
my_array[0][key2] value2
Ejemplo:
To pass param1=[{name:test_name, value:test_value}, {...}]
param1[0][name] test_name
param1[0][value] test_value
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-04 18:23:08
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-04 22:54:16
En los encabezados set
content-type : application/x-www-form-urlencoded
En el cuerpo seleccione la opción
X-www-form-urlencoded
E insertar datos como matriz json
user_ids : ["1234", "5678"]
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-04 14:37:21
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-06-30 14:33:31
Elija form-data o urlencoded y use la misma clave "user_ids". El servidor debe recibirlo como una matriz.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-10-06 20:21:42
{
"data" : [
{
"key1" : "value1",
"key2" : "value2"
},
{
"key01" : "value01",
"key02" : "value02"
},
{
"key10" : "value10",
"key20" : "value20"
}
]
}
Puedes pasar así. Espero que esto ayude a alguien.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-07-13 13:12:27
Esto también funciona para las listas dentro del objeto:
Id:37
IdParent:26
Name:Poplet
Values[0].Id:1349
Values[0].Name:SomeName
Values[1].Id:1350
Values[1].Name:AnotherName
El JSON equivalente sería:
{
"Id": 37,
"IdParent": 26,
"Name": "Poplet",
"Values": [
{
"Id": 1349,
"Nombre": "SomeName"
},
{
"Id": 1350,
"Nombre": "AnotherName"
}
]
}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-10-25 12:06:35
Probé todas las soluciones aquí y en otros posts, pero nada ayudó.
La única respuesta me ayudó:
Adición del atributo [FromBody] antes de la decleración del parámetro en la firma de la función:
[Route("MyFunc")]
public string MyFunc([FromBody] string[] obj)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-01-09 09:16:01
En forma-datos,
key value
user_ids[] 1234
user_ids[] 5678
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-01-16 10:25:43
Es importante saber que el campo valor solo puede contener un valor (sin especificadores).
Si desea enviar, por ejemplo, una matriz de "mensajes" con Postman, cada uno con una lista de pares clave/valor, ingrese, por ejemplo, messages [] [reason] como clave y el valor de reason en value:
El servidor recibirá:
{"messages"=>[{"reason"=>"scrolled", "tabid"=>"2"}, {"reason"=>"reload", "tabid"=>"1"}], "endpoint"=>{}}
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-09-07 08:15:09
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-09-17 11:04:44