Hi Folks,
I have an install of 3.0.2.0 that is running really well, but I want to add a feature through the API and cannot figure out the workflow. Meaning, I am guessing the API works in a way that the external party sends in a login request, gets back a session token, and only then can the external source send a request to add things like products to the cart using the token sent. Does that seem right?
I am trying to use mailparser to get specific types of emails (reservations from Airbnb, we use OC to rent houses). Mailparser does a good job doing the parse and creating a JSON of the info I need, and it can then push it to the API as an HTTP POST request (either JSON or html form).
With the existing APIs, if I have the workflow correct, it means I cannot use them? - as mailparser does a one off push.
Does anyone have a suggestion of how to set up the custom API? I tried combining the login and order add into a custom API, but opencart still has issues with the session and tries to redirect, giving me a 301 error back in mailparser. I get nothing in the OC error log, I have the dev tab open using firefox.
I tried to keep it simple and initially just try to insert the info from mailparser into a new table in my OC db... I can figure out the rest if I can get this bit working.
Thanks for any help!
The API doesn't redirect. It should always return a JSON response. Are you calling the correct API URL?
Thanks for the response. Good question. I usedADD Creative wrote: ↑Tue Jul 26, 2022 11:12 pmThe API doesn't redirect. It should always return a JSON response. Are you calling the correct API URL?
http://www.{my domain}.com/index.php?route=api/login
in mailparser.io, just to try and use the standard login module supplied by opencart, and got the same answer! 301. As you mentioned, I should have got a json back with an error? Is this syntax for the URL wrong?
If I enter the same url straight in the browser, I get
Notice: Undefined index: api_token in /home4/bumblef7/public_html/catalog/controller/startup/session.php on line 8 - I assume that it got there?
Check it's not a redirect between http and https that you are seeing.
You need to switch off displing of error in all 3 places, PHP, config and settings. Otherwise minor notices could mess up the JSON response.
You need to switch off displing of error in all 3 places, PHP, config and settings. Otherwise minor notices could mess up the JSON response.
hmm interesting, I get a 301 with http and 200 with https. So you were spot on, it was the redirection between the two. Odd, but good to know. Thanks for your help! I should nail the rest from here.ADD Creative wrote: ↑Wed Jul 27, 2022 5:31 amCheck it's not a redirect between http and https that you are seeing.
You need to switch off displing of error in all 3 places, PHP, config and settings. Otherwise minor notices could mess up the JSON response.
Who is online
Users browsing this forum: Majestic-12 [Bot] and 32 guests