How to send an array through an HTTP service in Adobe Flex 3

How to send an array to Httpservice in Adobe Flex3

+3
source share
4 answers

I'm not quite sure what you mean by sending an array to httpservice. If you want to send an array to httpservice with the same field name, you can pass the array as the field value.

var service:HTTPService = new HTTPService();
service.useProxy = true;
service.destination = "myservicet";
service.resultFormat = HTTPService.RESULT_FORMAT_XML;

var fields:Array = ["categories", "organisation"];
var params:Object = new Object();
params.q = "stackoverflow";
params.rows = 0;
params.facet = "true";
params["facet.field"] = fields;
service.send(params);

HTTPService converts this to URL parameters:

facet = true & q = stackoverflow & facet% 2Efield = categories & facet% 2Efield = organization & rows = 0

Hope this helps!

Added for clarity. When there is only 1 argument in an array, do not pass the fields as an array. For some reason, flex won't send this to the http service

+7
source

. PHP, :

var fields:Array = ["categories", "organisation"];
var params:Object = {};
params.q = "stackoverflow";
params.rows = 0;
params.facet = "true";
params["facet.field[]"] = fields;
service.send(params);

PHP . AFAIR Rails.

+2

if it is a simple string array, you can join it well with the char delimiter, and from another site, split the string with the same delimiter into an array.

0
source

If it is a simple array, you can send it as a comma separated string.

httpService.request = new object;
httpService.request.csv = array.toString ();

0
source

Source: https://habr.com/ru/post/1698955/


All Articles