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

2 Likes

Can this be put into ideas, that is filter parameter, like date, for API ?

Can what be put into ideas? You are responding to a thread pertaining to a Manager version that is now several hundred versions out of date.

@Tut, like @MarkLL points out, a filter parameter for API calls for Manager can’t be utilized. Also I could not find anything which solves this in the forum.

As an example, if a company has many years of accounting data in Manager and only wants to query with API the current year data and not having to move also alls data from previous years into say Excel, then a date parameter for API calls would solve that

API calling a localisation and passing parameters normal accepted by the localisation would probably be more powerful. It may also involve less later customisation for NG Software as technical users & contract programmers could then implement any function they wanted.

I don’t think localisation will nearly suffice for those using BI tools or want full capabilities of Excel auto refresh etc. Also companies in Manager each use all sorts of custom fields and want their speed and flexibility to move 100% all data, including custom fields data, to BI tools without having to go through localisation in Manager as additional layer.

Don’t misunderstand me, I have nothing against localisation and actually think it serves good purpose for standardised reports in each country. API is just ubiquitous these days and BI tools have greatly advanced and even so some larger companies/enterprises are starting to phase out data warehouses (skipping layers) to save on IT cost and get their data straight into BI tools.

As API is already built into Manager and it does mostly work well, I think updates to API parameters would be a good option

The suggestion was you continue to use the API interface and external tools but you write a localisation / liquid code interface to deliver what ever data your external system needs.

Almost all data and searching is available within a localisation. An API call to a custom localisation would give the same access to your external application.

With an API to the users own localisation, the user would implement any required search and processing themselves.

Ok good we agree then on getting the data to the external tools :slight_smile:

I actually think those capable of using BI tools will have no problem with using APIs and I have seen here in the forum that many users are already extracting data from Manager with API