Forum

REST API broken?

Yayınlanan kategoriDevelopment
  • Lennart Behr    ( User ) 9 months ago
    Hello there,

    Whenever I try to retrieve data from the API I get empty data sets. I created two customers for testing and when I GET @ index.php/api/customers with valid authorization the response contains an empty data array. Also, I can't create customers using the API @ index.php/api/customers with the request body looking like this:

    {
    "email": "[email protected]",
    "name": "test test",
    "currency_code": "EUR"
    }

    What am I missing?

    Regards,
    L. Behr
  • Lennart Behr    ( User ) 9 months ago
    Note:
    When I try to create a customer the response contains this:

    […] "message": "The given data failed to pass validation.",
    "status_code": 500, […]
  • Gert-Jaap Glasbergen    ( User ) 8 months ago
    I am currently seeing the exact same thing.
  • Gert-Jaap Glasbergen    ( User ) 8 months ago
    When I try to fetch a customer directly from an ID (like '/api/customers/59') I get this:

    "message": "get_class() expects parameter 1 to be object, null given",
    "status_code": 500,
    "debug": {
    "line": 126,
    "file": "/var/www/html/vendor/dingo/api/src/Http/Response/Factory.php",
    "class": "ErrorException",
    "trace": [
    "#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'get_class() exp...', '/var/www/html/v...', 126, Array)",
    "#1 /var/www/html/vendor/dingo/api/src/Http/Response/Factory.php(126): get_class(NULL)",
    "#2 /var/www/html/app/Http/Controllers/Api/Incomes/Customers.php(42): Dingo\\Api\\Http\\Response\\Factory->item(NULL, Object(App\\Transformers\\Income\\Customer))",

    [...]
  • Gert-Jaap Glasbergen    ( User ) 8 months ago
    Ah, hold up. You need to pass the company_id (the ID of the company in Akaunting). Which, if you only have one, would be 1. So try /api/customers?company_id=1
  • Adil    ( User ) 6 months ago
    I am also stuck with somewhat same issue, I am trying with vendors api
    http://akaunting.example.com/api/vendors
    with GET method returns :
    {
    "data": [],
    "meta": {
    "pagination": {
    "total": 0,
    "count": 0,
    "per_page": 15,
    "current_page": 1,
    "total_pages": 0,
    "links": []
    }
    }
    }

    I am expecting all the vendors info list here

    When tried to fetch a specific vendor with id the same error mentioned above is thrown, Tried giving company_id
    http://akaunting.example.com/api/vendors?company_id=1 return the same json output above mentioned
    Please help me with this
  • Adil    ( User ) 6 months ago
    error mentioned is : message": "get_class() expects parameter 1 to be object, null given"

    https://stackoverflow.com/questions/49751991/get-class-expects-parameter-1-to-be-object-null-given/50732125 got this link when googled , anything related to PHP version ? I am using php7.2
    I used Users api to query specific user that went successful :
    http://localhost:4040/api/users/1

Lütfen, cevap vermek için giriş yapın veya kayıt olun.