Open FSTristan opened 3 years ago
Can you please add example code showing the issue?
Issue edited. Code now included.
That's strange. The creation of a task with hours is in the tests here: https://github.com/tobiasbp/float_api/blob/master/tests/test_float_api.py#L432
Are you able to run the tests?
Yes and no. I was able to run the test file with no issues. However, when I copied the test_task()
function into my program, and modified the parameters of the create_task()
function, the same error message resulted.
I did notice something strange: The last parameter that I pass to the create_task()
function is what causes the error. Until now, I always had the hours
parameter as the final parameter of the function, and therefore the error message always said that the hours
parameter's data could not be validated. However, if the people_id
parameter was the last one passed, the same error message resulted BUT it said that the the people_id
data could not be validated. This also happened when the end_date
parameter was the final one. This also happened when I added the notes
parameter as the final argument.
So it appears that the last passed keyword argument is causing this data validation error. Please let me know if I can help further.
Please add the complete output from running your program, including error mesage(s).
Here is the full Traceback:
Traceback (most recent call last): File "C:/Users/Con/Desktop/float_work/create_task_errors.py", line 22, in <module> hours = 8 File "C:\Users\Con\AppData\Local\Programs\Python\Python37-32\lib\site-packages\float_api\float_api.py", line 461, in create_task return self._post('tasks', kwargs) File "C:\Users\Con\AppData\Local\Programs\Python\Python37-32\lib\site-packages\float_api\float_api.py", line 157, in _post raise DataValidationError("API could not validate the data you posted" ) float_api.float_api.DataValidationError: API could not validate the data you posted
Hello, has there been any progress on this mystery?
Thanks!
Note the same issue is present with the .create_timeoff()
method.
It would be great if you could provide a python script that throws the errors. Then I could easily see if I could replicate. Since all the methods were tested, I'm wondering if something changed in the Float API?
On Thu, May 6, 2021 at 2:29 PM FSTristan @.***> wrote:
Note the same issue is present with the .create_timeoff() method.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tobiasbp/float_api/issues/22#issuecomment-833483314, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABLIRKYNUQIV3FUY4GD6RJLTMKDSJANCNFSM43L5NKJQ .
I was looking through your source code, and I was coming to the same conclusion. You have multiple methods using the exact same logic, yet only some of them don't work. Perhaps it has something to do with the dates?
Below is a script that will throw various errors; check the comments about each method call.
# Code to demonstrate errors with the create_task() method and create_timeoff() method
from float_api import FloatAPI
FLOAT_ACCESS_TOKEN = "your token string"
PEOPLE_ID = 17871680
PROJECT_ID = 6110885
TIMEOFF_TYPE_ID = 157931
# Create a Float API instance
api = FloatAPI(
access_token = FLOAT_ACCESS_TOKEN,
application_name = 'DataValidationErrorTesting',
contact_email = 'Name@email.com'
)
# There are 4 methods that use a comparison to required_fields
# They are:
# create_holiday no problems
# create_milestone no problems
# create_task yes problems
# create_timeoff yes problems
# Test to create holiday - Works
api.create_holiday(
name = "Test Holiday",
date = "2022-03-11"
)
print("Holiday created.")
# Test to create milestone - Works
api.create_milestone(
project_id = PROJECT_ID,
name = "Test Milestone",
date = "2021-05-07"
)
print("Milestone created.")
# Test to create time off - Does not work
# This will throw a DataValidationError stemming from the last kwarg, in the below case, for hours
api.create_timeoff(
timeoff_type_id = TIMEOFF_TYPE_ID,
start_date = "2021-05-20",
end_date = "2021-05-21",
people_ids = [PEOPLE_ID],
hours = 6
)
print("Timeoff created.")
# Test to create a task - Does not work
# This will throw a DataValidationError stemming from the last kwarg, in the below case, for people_id
api.create_task(
project_id = PROJECT_ID,
start_date = "2021-05-10",
end_date = "2021-05-11",
hours = 6,
people_id = PEOPLE_ID
)
print("Task created.")
# Test to create a task - Does not work
# This will throw a DataValidationError stemming from the last kwarg, in the below case, for start_date
api.create_task(
project_id = PROJECT_ID,
end_date = "2021-05-07",
hours = 6,
people_id = PEOPLE_ID,
start_date = "2021-05-01"
)
print("Task created.")
The required keyword argument
hours
always causes afloat_api.float_api.DataValidationError: API could not validate the data you posted
when thefloat_api.FloatAPI.create_task()
method is called.The error is thrown regardless of the datatype the argument is:
integer
,float
,list
,string
all cause it.Note the
hours
keyword argument in other methods, such asfloat_api.FloatAPI.update_task()
does not cause this error.Edit, example code added.