REST API Example postman

04.04.2024 15:31
#1
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Сообщения: 25965
Quote
REST API Example postman

REST API Example postman
api.postman_collection.zip

 
26.04.2024 11:45
#2
ecoShopUser
Joomshopping forum user no avatar
Name: Andrea
13.08.2012
Сообщения: 250
Quote
Aw: REST API Example postman

Hi.
i tried the rest api for joomla 4 it works fine until i use parameters.
for example i want to get user items:

$curl = curl_init('.../de/?option=com_jshopping&controller=addon_api');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query([
'section' => 'user',
'task' => 'items',
'args' => ['ids' => [2129,2342]],
]));
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $shop_token
]);

the curl answer is:

"<!DOCTYPE html>
<html lang="de-de" dir="ltr">
<head>
<meta charset="utf-8" />
<title>Fehler: 0 Joomla\CMS\User\UserFactory::loadUserByUsername(): Argument #1 ($username) must be of type string, null given, called in /var/www/html/ecodmsmdl/libraries/src/User/User.php on line 283</title>
<meta charset="utf-8">
...
"

i dont know what i'm doing wrong here

greetz
ingo

JoomShopping API 2.2.1


Joomla: 4.4.3 Stable
JoomShopping: 5.3.4
PHP: 8.3
 
26.04.2024 12:12
#3
admin
(Support Team)
User admin
Name: Admin
05.08.2010
Сообщения: 25965
Quote
Aw: REST API Example postman

Try use php example:

https://www.webdesigner-profi.de/joomla-webdesign/example/client_api_php.zip


-----------------------------
Try:
$curl = curl_init('.../de/?option=com_jshopping&controller=addon_api');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query([
'section' => 'user',
'task' => 'items',
'args' => ['ids' => ['2129','2342']],
]));
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $shop_token
]);

 
26.04.2024 15:47
#4
ecoShopUser
Joomshopping forum user no avatar
Name: Andrea
13.08.2012
Сообщения: 250
Quote
Aw: REST API Example postman

i have done it exact the same way. i found that the error only occurs on id's that doesn't exist in the users table but in the jshopping_users table.
the two have different number of users, i think maybe because of deleted users.
on a api call with an id that doesn't exist in both, i get the correct 'unknown user id' error result from curl.
in a joomla 3 system it works. maybe there something messed up with my database

 


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.