Skip to content

Conversation

PhilippRieth
Copy link

Hi,

The issue I encountered was when creating a new time entry via POST to '/time/entries' (REST API Time Documentation: Create Time Entry.) The API default value for 'addToDetailDescriptionFlag' is 'True.'

The following code can be used to reproduce the error:

time_entry_json = {"chargeToId": self.id,
                               "chargeToType": charge_to_type,
                               "timeStart": time_start.strftime("%Y-%m-%dT%H:%M:%SZ"),
                               "timeEnd": time_end.strftime("%Y-%m-%dT%H:%M:%SZ"),
                               "member": {'id': resource.id},
                               "notes": note_text,
                               "addToDetailDescriptionFlag": False,
                               "addToInternalAnalysisFlag": True,
                               "billableOption": billable_option
                               }
time_entry_tmp = time_entry.TimeEntry(time_entry_json)
my_api = time_entries_api.TimeEntriesAPI(url=self.cw_model.API_URL, auth=self.cw_model.basic_auth)
myapi.create_time_entry(time_entry_tmp)

When converting the TimeEntry object to a dict in the method _create, will not include any object attribute that was purposely set to False. Thus, it will later not be included in the POST which results in the value " "addToDetailDescriptionFlag": False" not actually being POSTed to the API endpoint.

Reach out if you got any questions!

Regards,
Philipp

@markciecior markciecior merged commit 9714c98 into markciecior:master Jan 25, 2024
@markciecior
Copy link
Owner

Thanks @PhilippRieth , sorry it took so long. I will bump pypi this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants