0

First off, I'm really new to the python requests module and using API in general. Chances are I made a basic mistake somewhere.

I'm trying to retrieve data from the exactonline API. Some data (eg: list of projects and cost transactions) I can retrieve relatively simply, so bearer code and current division should be ok. However, when I try to request data regarding hours worked I get only Null and 0 values.

I'm using requests as specified by this page: https://start.exactonline.nl/docs/HlpRestAPIResources.aspx?SourceAction=10

To be specific, I've tried these 4 functions:

  1. RecentHours
  2. HoursByDate
  3. HoursById
  4. RecentHoursByNumberOfWeeks

For RecentHours I use

    headers = {'Authorization': 'Bearer ' + bearer_token}
    result = requests.get('https://start.exactonline.nl/api/v1/' + CURRENT_DIVISION + "/read/project/RecentHours",
                          headers=headers,
                          params=query_args)
    return(result.text)

For HoursByWeek I use (I currently only request one piece of information because that way I'm sure I didn't make any typo's in the query_args):

    headers = {'Authorization': 'Bearer ' + bearer_token}
    query_args = {'numberOfWeeks': '15',
                  'select': 'AccountCode'}
    result = requests.get('https://start.exactonline.nl/api/v1/' + CURRENT_DIVISION + "/read/project/RecentHoursByNumberOfWeeks",
                          headers=headers,
                          params=query_args)
    return(result.text)

All return status code 200, and no data.

According to this page (https://support.exactonline.com/community/s/knowledge-base?language=en_GB#All-All-DNO-Content-resp-codes-error-handling) this means I don't have access rights to this information. However, when I log in without using API I can access this information, so that seems strange to me. I've also tried logging in with the account with the highest freedom, but this still returns only null information.

Nathan
  • 3,558
  • 1
  • 18
  • 38
  • Providing code you have been trying will make it very simple. – Elis Byberi Nov 24 '17 at 13:30
  • Thanks, I added two example requests. – Nathan Nov 24 '17 at 13:49
  • HTTP 200 tells you the request was handled okay. What do you mean with 'no data' exactly? – Patrick Hofman Nov 24 '17 at 13:51
  • How many digits does the `CURRENT_DIVISION` variable have? – Patrick Hofman Nov 24 '17 at 13:51
  • It returns a file that I parse with xml.etree.cElementTree. However, all the values (amount of hours worked, date, cost, name of worker etc) are set to Null or 0. This is not a mistake from the xml parser as the raw script does not contain any values either. According to the exact support this means I don't have access rights but that doesn't make sense as I can see the information when I manually log in. – Nathan Nov 24 '17 at 13:53
  • CURRENT_DIVISION has 6 digits, I'm pretty sure that's correct as it does allow me to retrieve a lot of other data. – Nathan Nov 24 '17 at 13:54
  • As a suggestion, you can try to use a free tool from our company ([Invantive Query Tool](http://download.invantive.com/)) to see if the information is actually available and accessible or not. If it works there, the fault is probably on your side. – Patrick Hofman Nov 24 '17 at 14:02
  • In the Query Tool you can do 'set use-log-xml true', dito for REST, to log payload to folder (default is c:\temp) and also check the calls made in 'select * from sessionios@datadictionary'. – Guido Leenders Nov 24 '17 at 14:14
  • Do you mean like so? https://stackoverflow.com/questions/16337511/log-all-requests-from-the-python-requests-module – Nathan Nov 24 '17 at 14:27
  • No. That is in the Invantive Query Tool. It shows you what actions were made and that can help you develop your code. – Patrick Hofman Nov 24 '17 at 14:38

1 Answers1

0

The exactonline help desk says these four functions only allow you to request your own hours. If you want to request all hours use: /manufactering/TimeTransactions instead. (https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=ManufacturingTimeTransactions)

Nathan
  • 3,558
  • 1
  • 18
  • 38