Hi,
I'd like to add products to the catalog using an endpoint so I first tried to use admin/index.php?route=api/login to have an user_token but I always get an html response of the login page.
I added 127.0.0.1 and my ip address using https://whatismyipaddress.com/fr/mon-ip for the "Default" user and here's the call. I also tried insomnia/postman :
fetch('http://localhost/opencart/upload/admin/ ... =api/login', {
method: 'post',
body: JSON.stringify({
username: 'Default',
key: 'ca41f235723f4f042ff4eb641c70cf9fb8cc04553b97de2ce193be45f7281186c59c2e85b4885347655593aa0d27bb7ae49842e741ad4c4113a9b594a04c31f63b24db2ca47b8c25457d9659f3130416a8bb40e25704f3ce28dbe90d374dd791667fb1df3c9589900f57d67806d095c1c3f7178efe6f99a2ef7035d0d42809ec'
}),headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
})
Cheers,
I'd like to add products to the catalog using an endpoint so I first tried to use admin/index.php?route=api/login to have an user_token but I always get an html response of the login page.
I added 127.0.0.1 and my ip address using https://whatismyipaddress.com/fr/mon-ip for the "Default" user and here's the call. I also tried insomnia/postman :
fetch('http://localhost/opencart/upload/admin/ ... =api/login', {
method: 'post',
body: JSON.stringify({
username: 'Default',
key: 'ca41f235723f4f042ff4eb641c70cf9fb8cc04553b97de2ce193be45f7281186c59c2e85b4885347655593aa0d27bb7ae49842e741ad4c4113a9b594a04c31f63b24db2ca47b8c25457d9659f3130416a8bb40e25704f3ce28dbe90d374dd791667fb1df3c9589900f57d67806d095c1c3f7178efe6f99a2ef7035d0d42809ec'
}),headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
})
Cheers,
OC version.luxfero wrote: ↑Thu May 16, 2024 3:41 amHi,
I'd like to add products to the catalog using an endpoint so I first tried to use admin/index.php?route=api/login to have an user_token but I always get an html response of the login page.
I added 127.0.0.1 and my ip address using https://whatismyipaddress.com/fr/mon-ip for the "Default" user and here's the call. I also tried insomnia/postman :
fetch('http://localhost/opencart/upload/admin/ ... =api/login', {
method: 'post',
body: JSON.stringify({
username: 'Default',
key: 'ca41f235723f4f042ff4eb641c70cf9fb8cc04553b97de2ce193be45f7281186c59c2e85b4885347655593aa0d27bb7ae49842e741ad4c4113a9b594a04c31f63b24db2ca47b8c25457d9659f3130416a8bb40e25704f3ce28dbe90d374dd791667fb1df3c9589900f57d67806d095c1c3f7178efe6f99a2ef7035d0d42809ec'
}),headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
})
Cheers,
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Personally I wouldn't bother with the API, I'd just make a page that adds them either directly to the database or with the addProduct() method.
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Hi, it's 4.0.2.3straightlight wrote: ↑Thu May 16, 2024 5:49 pmOC version.luxfero wrote: ↑Thu May 16, 2024 3:41 amHi,
I'd like to add products to the catalog using an endpoint so I first tried to use admin/index.php?route=api/login to have an user_token but I always get an html response of the login page.
I added 127.0.0.1 and my ip address using https://whatismyipaddress.com/fr/mon-ip for the "Default" user and here's the call. I also tried insomnia/postman :
fetch('http://localhost/opencart/upload/admin/ ... =api/login', {
method: 'post',
body: JSON.stringify({
username: 'Default',
key: 'ca41f235723f4f042ff4eb641c70cf9fb8cc04553b97de2ce193be45f7281186c59c2e85b4885347655593aa0d27bb7ae49842e741ad4c4113a9b594a04c31f63b24db2ca47b8c25457d9659f3130416a8bb40e25704f3ce28dbe90d374dd791667fb1df3c9589900f57d67806d095c1c3f7178efe6f99a2ef7035d0d42809ec'
}),headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
})
Cheers,
My first option is to use an endpoint to add the product to the catalog because I also need to upload images. I thought about using database directly but I'll have to setup an sftp to set the image to the remote server where the opencart site is.paulfeakins wrote: ↑Thu May 16, 2024 7:34 pmPersonally I wouldn't bother with the API, I'd just make a page that adds them either directly to the database or with the addProduct() method.
See this solution: https://github.com/opencart/opencart/co ... 1fb58cf489 .luxfero wrote: ↑Thu May 16, 2024 8:20 pmMy first option is to use an endpoint to add the product to the catalog because I also need to upload images. I thought about using database directly but I'll have to setup an sftp to set the image to the remote server where the opencart site is.paulfeakins wrote: ↑Thu May 16, 2024 7:34 pmPersonally I wouldn't bother with the API, I'd just make a page that adds them either directly to the database or with the addProduct() method.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
not working :/ . What use for oc_get_ip btw ? It's not used anywhere in the project.straightlight wrote: ↑Thu May 16, 2024 10:53 pmSee this solution: https://github.com/opencart/opencart/co ... 1fb58cf489 .luxfero wrote: ↑Thu May 16, 2024 8:20 pmMy first option is to use an endpoint to add the product to the catalog because I also need to upload images. I thought about using database directly but I'll have to setup an sftp to set the image to the remote server where the opencart site is.paulfeakins wrote: ↑Thu May 16, 2024 7:34 pm
Personally I wouldn't bother with the API, I'd just make a page that adds them either directly to the database or with the addProduct() method.
Cheers,
Your URL is wrong. You need to remove admin from the path. You also will not find anything in the API for adding products.
It is, now, in OC v4.1.0.0 (dev) release.luxfero wrote: ↑Fri May 17, 2024 12:24 amnot working :/ . What use for oc_get_ip btw ? It's not used anywhere in the project.straightlight wrote: ↑Thu May 16, 2024 10:53 pmSee this solution: https://github.com/opencart/opencart/co ... 1fb58cf489 .
Cheers,
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
No you wouldn't, you can use PHP to get a file into the filesystem very easily with someting like curl or file_get_contents().
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Who is online
Users browsing this forum: grgr and 7 guests