flutter joomshopping api

15.07.2022 14:21
#1
gooodwin67
Joomshopping forum user no avatar
Name: Andrey
30.07.2015
Сообщения: 2
Quote
flutter joomshopping api

i connect to api from flutter.
i can get category - item

var responseCategory = await http.post(
Uri.parse(
'https://example.ru/index.php?option=com_jshopping&controller=addon_api'),
headers: {'Authorization': 'Bearer $token'},
body: {
"section": "category",
"task": "item",
"args[id]": "1",
},
);


But if i must post "int array" i have error "Request error. Wrong argument(s). Argument 'ids' must be of the type array, string given, result: []"


var responseCategory = await http.post(
Uri.parse(
'https://example.ru/index.php?option=com_jshopping&controller=addon_api'),
headers: {'Authorization': 'Bearer $token'},
body: {
"section": "category",
"task": "items",
"args[ids]": "[1,2,3]",
},
);


 
15.07.2022 20:35
#2
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Сообщения: 25942
Quote
Aw: flutter joomshopping api

"args[ids]": [1,2,3]

 
15.07.2022 23:02
#3
gooodwin67
Joomshopping forum user no avatar
Name: Andrey
30.07.2015
Сообщения: 2
Quote
Aw: flutter joomshopping api

i tried: error: type 'List<int>' is not a subtype of type 'String' in type cast

 
16.07.2022 00:11
#4
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Сообщения: 25942
Quote
Aw: flutter joomshopping api

Example for php

$curl = curl_init($site_url . '/index.php?option=com_jshopping&controller=addon_api');
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token
]);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query([
'section' => 'category',
'task' => 'item',
'args' => ['id' => 1]
]));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($curl);
curl_close($curl);
if ($res !== false) {
$res = json_decode($res, true);
}
print_r($res['result']);


-------------------------------------


$curl = curl_init($site_url . '/index.php?option=com_jshopping&controller=addon_api');
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $token
]);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query([
'section' => 'category',
'task' => 'items',
'args' => ['ids' => [1,2,3]]
]));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($curl);
curl_close($curl);
if ($res !== false) {
$res = json_decode($res, true);
}
print_r($res);


Последнее изменение: 16.07.2022 00:14
 


Copyrights MAXXmarketing GmbH. Alle Rechte vorbehalten
Durch die Nutzung dieser Website stimme ich zu, dass Cookies zur optimalen Gestaltung der Website sowie zur Analyse der Nutzung der Website verwendet werden. Weiterführende Informationen finden Sie hier. OK, einverstanden.