Json API issues

Hi,

I’m trying to use the manager API user@pass:manager-url/api/ route and it’s work fine.

I just found out that I can use some reports data by appending .json in the URL:

I tested in the browser while I have a session and worked fine, but I can’t use it without a session. It’s shows this error:

I tried using Authorization: Basic *credentials* header and I have same result.

Also, another thing that the json result does not respect the search filter in the tables &Term=*some-filter*, all results are shown always.

This is something that @lubos will need to investigate. He recently updated the api to fix a pdf creation bug. This is probably a different, but similar bug.

what’s the content of the “Internal Error” because I just tested a sales invoice view in 20.8.37 without a problem.

You may of entered a typo in your post, but it should be user:pass@manager-url/api/

Also do you have curl installed?

I have Windows 10 running DeskTop version and WSL with ubuntu 18.04 running mono and manager-server (set to use port 8123).

curl --ipv4 -v --get "http://administrator:@localhost:8123/api/index.json"

returns

* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8123 (#0)
* Server auth using Basic with user 'administrator'
> GET /api/index.json HTTP/1.1
> Host: localhost:8123
> Authorization: Basic YWRtaW5pc3RyYXRvcjo=
> User-Agent: curl/7.61.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Cache-Control: no-cache, no-store
< Content-Type: application/json
< Server: Mono-HTTPAPI/1.0
< Date: Wed, 12 Aug 2020 10:02:50 GMT
< Content-Length: 314
< Keep-Alive: timeout=15,max=100
<
[
  {
    "Key": "VGVzdGluZzAwMQ",
    "Name": "Testing001"
  },
  {
    "Key": "VGVzdGluZzAwMg",
    "Name": "Testing002"
  },
  {
    "Key": "VGVzdGluZzAwMw",
    "Name": "Testing003"
  },
  {
    "Key": "VGVzdGluZzAwNA",
    "Name": "Testing004"
  },
  {
    "Key": "Tm9ydGh3aW5k",
    "Name": "Northwind"
  }
]* Connection #0 to host localhost left intact

Then looking at an invoice for Northwind…

curl --ipv4 -v --get "http://administrator:@localhost:8123/sales-invoice-view.json?FileID=Tm9ydGh3aW5k&Key=4850f691-6abc-41d1-8e7a-3e8b5662db56"

which returns:

*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8123 (#0)
* Server auth using Basic with user 'administrator'
> GET /sales-invoice-view.json?FileID=Tm9ydGh3aW5k&Key=4850f691-6abc-41d1-8e7a-3e8b5662db56 HTTP/1.1
> Host: localhost:8123
> Authorization: Basic YWRtaW5pc3RyYXRvcjo=
> User-Agent: curl/7.61.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Cache-Control: no-cache, no-store
< Content-Type: application/json
< Server: Mono-HTTPAPI/1.0
< Date: Wed, 12 Aug 2020 09:45:41 GMT
< Content-Length: 1253
< Keep-Alive: timeout=15,max=100
<
{"title":"Invoice","description":null,"reference":"3002","emphasis":{"text":"Overdue","positive":false,"negative":true},"fields":[{"label":"Invoice date","text":"8/9/2020","emphasis":false},{"label":"Due date","text":"8/9/2020","emphasis":false},{"label":"Invoice number","text":"3002","emphasis":false}],"custom_fields":[],"table":{"columns":[{"label":"Description","align":"start","nowrap":false},{"label":"Qty","align":"center","nowrap":true},{"label":"Unit price","align":"right","nowrap":true},{"label":"Amount","align":"right","nowrap":true}],"rows":[{"cells":[{"value":null,"text":"14/07/2020 - Testing"},{"value":3.25,"text":"3.25 hours"},{"value":14.25,"text":"14.25"},{"value":46.31,"text":"46.31"}]},{"cells":[{"value":null,"text":"20/07/2020 - "},{"value":null,"text":"&nbsp;"},{"value":125.0,"text":"125.00"},{"value":125.0,"text":"125.00"}]}],"totals":[{"label":"Total","text":"$ 171.31","number":171.31,"emphasis":true}]},"business":{"logo":"/business-logo-view?Key=4f6ce09d-d6f8-4ce5-bf3e-163718d7c263&FileID=Tm9ydGh3aW5k","name":"Northwind","address":null,"custom_fields":[]},"recipient":{"code":null,"name":"Around the Horn","address":"120 Hanover Sq.\r\nLondon NULL WA1 1DP\r\nUK\r\n","identifier":null,"email":null,"telephone":null}}* Connection #0 to host localhost left intact

Your error seems to indicate it may be an authentication error

I agree in regard to &Term=*some-filter* does not work. It would be really helpful if it did :slightly_smiling_face:

The problem presets in cloud/server editions … since the desktop edition doesn’t use authentication.

Ohh … thank you for correcting that :sweat_smile:
Anyway as I said the /api/ path working fine as expected what is not working is normal URLs that end with .json

I found that the issue happened only in the administrator user, then I checked my users and there were two users with administrator as username :neutral_face:, I just delete the one with red color and everything works fine now.

The remaining issue is this, I hope @lubos fix this soon.

So just an FYI… It is possible to get a list of All Invoices for a single Customer in json format.

If you browse to the Customer tab and check the links in the “Invoices” column you will see it includes a Customer parameter and uuid. Just add the .json and it will look like the following.

/sales-invoices.json?Customer=74c350ab-bbd2-4609-a1ae-4c58e8d548e6&FileID=Tm9ydGh3aW5k

1 Like