We reserve the right to log and verify your API calls and to contact you if we detect abuse on your part. For example:
- the requests takes too long to return
- the requests return too much data at a time
- The requests are too frequent
We strongly suggest using the date filter parameters to return only the data that is relevant.
Best practice for SaveWorkItem function
These parameters are exclusive to Timeclocks:
If you try to pass those parameters for a normal time entry, you'll receive an error, even if you pass a NULL value.
https://api.aceproject.com/?fct=saveworkitem&guid=61901901-d493-426a-8519-eabbaa2cb90e&userid=NULL×heetlineid=NULL&weekstart=NULL&projectid=NULL&taskid=NULL&timetypeid=NULL&hoursday1=NULL&hoursday2=NULL&hoursday3=NULL&hoursday4=NULL&hoursday5=NULL&hoursday6=NULL&hoursday7=NULL&indatetime=NULL&outdatetime=NULL&comments=NULL&format=DS
Guid |
String |
False |
|
|
|
|
|
True |
Unique identifier for the authenticated user. The GUID has an expiry date and time which is managed automatically by the API. |
UserId |
Integer |
True |
|
|
NULL |
|
|
False |
Auto-generated unique identifier of a user. The time item is created for that user. If nothing, the item will be created for the current user (guid) |
TimesheetLineId |
Integer |
True |
|
|
NULL |
False |
True |
|
Auto-generated unique time sheet entry (work item) identifier. |
WeekStart |
DateTime |
True |
|
|
NULL |
True |
False |
|
Date of start of the week on which the item will be created or updated time. If the date is not the first day of the week as specified in the account information, the system finds the first day of the week including the specified date. |
ProjectId |
Integer |
True |
|
|
NULL |
|
|
False |
Auto-generated unique identifier of a project. Optional if TaskId exists. |
TaskId |
Integer |
True |
|
|
NULL |
|
|
False |
Auto-generated unique identifier of a task. |
TimetypeId |
Integer |
True |
|
|
NULL |
True |
False |
|
Auto-generated unique identifier of a time type. |
HoursDay1 |
Decimal |
True |
|
0 to 24 |
NULL |
|
|
False |
Number of hours for the time sheet entry (work item) on the first day of the week. |
HoursDay2 |
Decimal |
True |
|
0 to 24 |
NULL |
|
|
False |
Number of hours for the time sheet entry (work item) on the second day of the week. |
HoursDay3 |
Decimal |
True |
|
0 to 24 |
NULL |
|
|
False |
Number of hours for the time sheet entry (work item) on the third day of the week. |
HoursDay4 |
Decimal |
True |
|
0 to 24 |
NULL |
|
|
False |
Number of hours for the time sheet entry (work item) on the forth day of the week. |
HoursDay5 |
Decimal |
True |
|
0 to 24 |
NULL |
|
|
False |
Number of hours for the time sheet entry (work item) on the fifth day of the week. |
HoursDay6 |
Decimal |
True |
|
0 to 24 |
NULL |
|
|
False |
Number of hours for the time sheet entry (work item) on the sixth day of the week. |
HoursDay7 |
Decimal |
True |
|
0 to 24 |
NULL |
|
|
False |
Number of hours for the time sheet entry (work item) on the seventh day of the week. |
InDatetime |
DateTime |
True |
|
|
NULL |
|
|
False |
Start datetime of the time clock. |
OutDatetime |
DateTime |
True |
|
|
NULL |
|
|
False |
End datetime of the time clock. |
Comments |
String |
True |
|
|
NULL |
|
|
False |
Any user-defined comment related to the time sheet entry (work item). |
Format |
String |
False |
|
RS: RecordSet DS: DataSet JSON: JSON |
DS |
|
|
True |
Return Format |
Public Class Sample
Public Sub CodeSample_saveworkitem()
Dim strXML As String = String.Empty
Dim dsOutput As DataSet = Nothing
Dim guid As String = String.Empty
Dim sb As New System.Text.StringBuilder
Try
sb = New System.Text.StringBuilder
sb.Append("fct=saveworkitem")
sb.Append(String.Format("&guid={0}", "ea4bf070-1dd4-4337-a301-c3072faee7ef"))
sb.Append(String.Format("&userid={0}", "NULL"))
sb.Append(String.Format("&timesheetlineid={0}", "NULL"))
sb.Append(String.Format("&weekstart={0}", "NULL"))
sb.Append(String.Format("&projectid={0}", "NULL"))
sb.Append(String.Format("&taskid={0}", "NULL"))
sb.Append(String.Format("&timetypeid={0}", "NULL"))
sb.Append(String.Format("&hoursday1={0}", "NULL"))
sb.Append(String.Format("&hoursday2={0}", "NULL"))
sb.Append(String.Format("&hoursday3={0}", "NULL"))
sb.Append(String.Format("&hoursday4={0}", "NULL"))
sb.Append(String.Format("&hoursday5={0}", "NULL"))
sb.Append(String.Format("&hoursday6={0}", "NULL"))
sb.Append(String.Format("&hoursday7={0}", "NULL"))
sb.Append(String.Format("&indatetime={0}", "NULL"))
sb.Append(String.Format("&outdatetime={0}", "NULL"))
sb.Append(String.Format("&comments={0}", "NULL"))
sb.Append(String.Format("&format={0}", "DS"))
strXML = CallHttp("https://api.aceproject.com/", sb.ToString)
dsOutput = Deserialize(Of DataSet)(strXML)
If dsOutput IsNot Nothing AndAlso dsOutput.Tables.Count > 0 Then
If dsOutput.Tables.Contains("dtAPIErrors") Then
Throw New Exception(String.Format("{0}: {1}", _
dsOutput.Tables(0).Rows(0).Item("ErrorNumber").ToString, _
dsOutput.Tables(0).Rows(0).Item("ErrorDescription").ToString))
End If
End If
Catch ex As Exception
Throw
Finally
If sb IsNot Nothing Then sb = Nothing
If dsOutput IsNot Nothing Then
dsOutput.Dispose()
dsOutput = Nothing
End If
End Try
End Sub
Private Shared Function CallHttp( ByVal url As String, _
ByVal params As String) As String
Dim loHttp As System.Net.HttpWebRequest
loHttp = CType(System.Net.WebRequest.Create(url), System.Net.HttpWebRequest)
loHttp.Method = "POST"
Dim requestWriter As System.IO.StreamWriter = New System.IO.StreamWriter(loHttp.GetRequestStream())
If Not String.IsNullOrEmpty(params) Then
requestWriter.Write(params)
End If
requestWriter.Close()
loHttp.ContentType = "application/x-www-form-urlencoded"
loHttp.Headers.Set("Pragma", "no-cache")
loHttp.AllowAutoRedirect = True
loHttp.KeepAlive = True
loHttp.Timeout = 30 * 1000
Dim loWebResponse As System.Net.HttpWebResponse = CType(loHttp.GetResponse(), System.Net.HttpWebResponse)
Dim enc As Encoding = System.Text.Encoding.UTF8
Dim loResponseStream As System.IO.StreamReader = New System.IO.StreamReader(loWebResponse.GetResponseStream(), enc)
Dim lcHtml As String = loResponseStream.ReadToEnd()
loWebResponse.Close()
loResponseStream.Close()
Return lcHtml
End Function
Private Shared Function Deserialize(Of T)( ByVal strXML As String) As T
Dim objet As T = Nothing
Dim objType As Type = GetType(T)
Try
If Not String.IsNullOrEmpty(strXML) Then
Dim objSerializer As New System.Xml.Serialization.XmlSerializer(objType)
Dim objText As New System.Text.StringBuilder()
Dim objXmlReader As New System.IO.StringReader(strXML)
objet = DirectCast(objSerializer.Deserialize(objXmlReader), T)
objXmlReader.Close()
End If
Return objet
Catch ex As Exception
Throw
Finally
If objet IsNot Nothing Then objet = Nothing
End Try
End Function
End Class