2

while using api for opencart-3x i am not been able to generate api_token. I used Postman for sending post request but I am getting an "unexpected '<'" error in JSON format.Also I am using xampp local server.

I have searched every video , blogs regarding this Opencart-api. But i found nothing. One thing to add that I also tried the same on live server but the result was same. I also looked into the source code but was not been able to find anything. Please help me to get this working.

I am not been able to login through api username and api key. I am not been able to generate session ID. Please help me to do so

Unexpected '<'

i am getting this error and api_token is not generated. enter image description here

catcon
  • 1,135
  • 1
  • 6
  • 18
  • This kind of error usually shows up if the api you try to reach generates some kind of error instead of a proper json output. Maybe a 404 or 500 error. Can you see the full output somewhere? – Andrew Jul 12 '19 at 06:46
  • or even a `PHP: Notice` would trigger this. This should help you debug: https://stackoverflow.com/questions/1820927/request-monitoring-in-chrome – Cornel Raiu Jul 12 '19 at 06:50
  • I'm reading up on opencart's API, I've never used it before: it seems to me like you should delete the "admin/" from the postman link, and simply use "suruchiopencart/index.php?route=api/login" ... I'm not even certain it supports admin login to begin with. – Andrew Jul 12 '19 at 06:52
  • Hi Andrew , i used this link http://development.ssntpl.com/suruchiopencart/index.php?route=api/login . and still same error in json format . Plus in HTML format i am Getting 301 Permanently moved. – Sushil Sharma Jul 12 '19 at 07:08

1 Answers1

0

this is caused by syntax error in file. ./upload/catalog/controller/api/login.php

check the code with reference to this. https://github.com/opencart/opencart/blob/master/upload/catalog/controller/api/login.php

  • this helped me somehow but now instead of getting a json error , I am getting an empty array []. Please suggest something , it would a great help. – Sushil Sharma Jul 12 '19 at 07:28