Clarity

 View Only
Expand all | Collapse all

SOAP request fails when trying to Write Timesheet

Jump to Best Answer
Legacy User

Legacy UserJan 05, 2017 10:43 AM

  • 1.  SOAP request fails when trying to Write Timesheet

    Posted Jan 05, 2017 09:34 AM

    Hello dears,

    I'm trying to write timesheets but not getting the expected response: "XOG-2015: This timesheet can not be saved because it has since been updated by another user. Save your changes in a new file, then retrieve the same timesheet again and re-enter your time."

    I'm now stack on this message, I tryed many solutions but not working. Can somebody have a look on my query and tell me the wrong ?

    I tryed direct XOG, and SOAPUI, but same result, timesheet not updated

     

    ---------------------REQUEST----------------------

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:obj="http://www.niku.com/xog/Object">
    <soapenv:Header>
    <obj:Auth>
    <obj:Username>MyLogin</obj:Username>
    <obj:Password>MyPasswrd</obj:Password>
    </obj:Auth>
    </soapenv:Header>
    <soapenv:Body>
    <obj:WriteTimeperiod>
    <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_timeperiod.xsd">
    <Header version="14.4.0.234" action="write" objectType="timeperiod" externalSource="NIKU"/>
    <TimePeriods>
    <TimePeriod finish="2017-01-01T00:00:00" openForTimeEntry="true" start="2016-12-26T00:00:00">
    <TimeSheets>
    <TimeSheet ID="5392003" lastModified="2017-01-05T13:57:48" resourceID="MyResID"  action="replace" status="0" version="5">
    <TimeSheetEntries>
    <TimeSheetEntry assignmentEstimate="0" assignmentEstimateForTimePeriod="0" assignmentFinish="2016-12-23T17:00:00" assignmentID="5187053" assignmentPendingEstimate="0" assignmentStart="2015-11-18T08:00:00" chargeCodeID="Billable-FixedP" chargeCodeName="Facturable-Forfait" internalTaskID="5108117" projectID="Reporting" projectName="Reporting" roleID="CONS" taskName="Rapports 2015-11" totalActuals="24" typeCodeID="HSTD" typeCodeName="Heures Standards">
    <DailyActuals>
    <Actual actualDate="2016-12-26" amount="8"/>
    <Actual actualDate="2016-12-27" amount="8"/>
    <Actual actualDate="2016-12-28" amount="8"/>
    <Actual actualDate="2016-12-29" amount="0"/>
    <Actual actualDate="2016-12-30" amount="0"/>
    <Actual actualDate="2016-12-31" amount="0"/>
    </DailyActuals>
    </TimeSheetEntry>
    </TimeSheetEntries>
    </TimeSheet>
    </TimeSheets>
    </TimePeriod>
    </TimePeriods>
    </NikuDataBus>
    </obj:WriteTimeperiod>
    </soapenv:Body>
    </soapenv:Envelope>

     

     

    ------------------------------------ RESPONSE ----------------------

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Header/>
    <soapenv:Body>
    <SessionID xmlns="http://www.niku.com/xog">9938240__DEA9963C-F73C-483A-8428-176A61A6B53C</SessionID>
    <WriteTimeperiodResponse xmlns="http://www.niku.com/xog/Object">
    <XOGOutput xsi:noNamespaceSchemaLocation="../xsd/status.xsd">
    <Severity>FATAL</Severity>
    <Description>XOG-2015: This timesheet can not be saved because it has since been updated by another user. Save your changes in a new file, then retrieve the same timesheet again and re-enter your time.</Description>
    <Object type="timeperiod"/>
    <Status elapsedTime="0.013 seconds" state="SUCCESS"/>
    <Statistics failureRecords="0" insertedRecords="1" totalNumberOfRecords="1" updatedRecords="0"/>
    <Records/>
    <DeprecationInformation>
    <Severity>WARNING</Severity>
    <Description>DEPRECATION MESSAGE</Description>
    <Exception type="java.lang.Exception">The action and objectType attributes in the Header have been deprecated.</Exception>
    </DeprecationInformation>
    </XOGOutput>
    </WriteTimeperiodResponse>
    </soapenv:Body>
    </soapenv:Envelope>

     

     

     

     

     

    Thanks for your help,

    @mos



  • 2.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 05, 2017 10:43 AM

    Up



  • 3.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 05, 2017 02:14 PM

    Are you trying to create new timesheets or update existing ones?  (your XML looks like the latter)

     

    Perhaps read thru this thread (or search on that error message) and see if anything helps ; 

    XOG Adjusted Timesheets 



  • 4.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 06, 2017 08:02 AM

    Hi David,

    Thanks for this solution, but my application will not connect to CA database, so not possible to create stored procedure and then run it. I just want to update the timesheet by web services.

    It seems that there is a lock on the timsheet, is it possible to remove that lock through XOG ? is it possible to bypass this lock and update the timesheet ?

     

    Please, need your help guys to go ahead !

     

     

    Thanks,

    Amos



  • 5.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 06, 2017 08:23 AM

    Sorry - I pointed you at the wrong thread, my bad.

     

    I meant to refer to this one ; XOG - (adjustment timesheets) which has a long discussion on the variances in XML needed to get timesheets to XOG correctly. 



  • 6.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 06, 2017 10:41 AM

    Hi David,

    After reading your "adjustment timesheets" link and comments flows, I'm sure that I'm doing exactly what is advised. My process is below, I don't understang why it's not working

     

     

    1)------------------------- READ RESPONSE ---------------------
    <ReadTimeperiodResponse xmlns="http://www.niku.com/xog/Object">
    <NikuDataBus xsi:noNamespaceSchemaLocation="../xsd/nikuxog_timeperiod.xsd">
    <Header externalSource="NIKU" version="14.4.0.234"/>
    <TimePeriods>
    <TimePeriod finish="2016-12-12T00:00:00" openForTimeEntry="true" start="2016-12-05T00:00:00">
    <TimeSheets>
    <TimeSheet ID="5392000" lastModified="2017-01-06T13:37:59" resourceID="ResID" status="2" version="7">
    <TimeSheetEntries/>
    <Notes/>
    </TimeSheet>
    </TimeSheets>
    </TimePeriod>
    </TimePeriods>
    </NikuDataBus>
    </ReadTimeperiodResponse>


    2)----------------------------------- WRITE REQUEST ----------------------------
    <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_timeperiod.xsd">
    <Header version="14.4.0.234" action="write" objectType="timeperiod" externalSource="NIKU"/>
    <TimePeriods>
    <TimePeriod finish="2016-12-12T00:00:00" openForTimeEntry="true" start="2016-12-05T00:00:00">
    <TimeSheets>
    <TimeSheet ID="5392000" lastModified="2017-01-06T13:37:59" resourceID="MyResID" status="1" action="replace"version="8">
    <TimeSheetEntries>
    <TimeSheetEntry assignmentEstimate="0" assignmentEstimateForTimePeriod="0" assignmentFinish="2016-12-23T17:00:00" assignmentID="5187053" assignmentPendingEstimate="0" assignmentStart="2015-11-18T08:00:00" chargeCodeID="Billable-FixedP" chargeCodeName="Facturable-Forfait" internalTaskID="5108117" projectID="Reporting" projectName="Reporting" roleID="CONS" taskName="Rapports 2015-11" totalActuals="40" typeCodeID="HSTD" typeCodeName="Heures Standards">
    <DailyActuals>
    <Actual actualDate="2016-12-05" amount="8"/>
    <Actual actualDate="2016-12-06" amount="8"/>
    <Actual actualDate="2016-12-07" amount="8"/>
    <Actual actualDate="2016-12-08" amount="8"/>
    <Actual actualDate="2016-12-09" amount="8"/>
    <Actual actualDate="2016-12-10" amount="0"/>
    <Actual actualDate="2016-12-11" amount="0"/>
    </DailyActuals>
    </TimeSheetEntry>
    </TimeSheetEntries>
    </TimeSheet>
    </TimeSheets>
    </TimePeriod>
    </TimePeriods>
    </NikuDataBus>

     

    3)-----------------------------------WRITE RESPONSE
    <WriteTimeperiodResponse xmlns="http://www.niku.com/xog/Object">
    <XOGOutput xsi:noNamespaceSchemaLocation="../xsd/status.xsd">
    <Severity>FATAL</Severity>
    <Description>XOG-2015: This timesheet can not be saved because it has since been updated by another user. Save your changes in a new file, then retrieve the same timesheet again and re-enter your time.</Description>
    <Object type="timeperiod"/>
    <Status elapsedTime="0.016 seconds" state="SUCCESS"/>
    <Statistics failureRecords="0" insertedRecords="1" totalNumberOfRecords="1" updatedRecords="0"/>
    <Records/>
    <DeprecationInformation>
    <Severity>WARNING</Severity>
    <Description>DEPRECATION MESSAGE</Description>
    <Exception type="java.lang.Exception">The action and objectType attributes in the Header have been deprecated.</Exception>
    </DeprecationInformation>
    </XOGOutput>
    </WriteTimeperiodResponse>

     

     

    Thanks



  • 7.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 06, 2017 10:48 AM

    As you can tell from that other thread "its fiddly".

     

    Things I'd be concerned about would be;

    • That your original timesheets appears to be in a "submitted" state not an "open" one.
    • You are reading a submitted timesheet and writing an open one?
    • Whether you need to increment the "version" (or not)? (I don't know).
    • You don't appear to have a space between the variables here ; action="replace"version="8" (could just be formatting on the post though)
    • You are reading a timesheet for one resource and writing the same timesheet for a different resource? (a typo I assume)

     

    I honestly can't give you a better answer than just keep trying (many) different things though.



  • 8.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 06, 2017 10:58 AM

    Hi Dave,

     

    action="replace"version="8"  ---> This is copy/past issue because I removed a parametter.

     

    The version have to be incremented because Clarity increment the version whenever you edit  the timesheet

     

     

    Thanks



  • 9.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 06, 2017 11:32 AM

    In a test system I just read out an OPEN (not submitted) timesheet (with just one timeentry)

     

    I editted the XML;

    • incremented the version in the <TimeSheet header
    • added the action="replace" in the <TimeSheet header
    • removed lots of junk from the <TimeSheetEntry header - leaving only the assignmentID, projectID and taskID
    • amended some of the 'amounts'

     

    and I could XOG that back in OK and timesheet is updated in the application.



  • 10.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 06, 2017 11:56 AM

    Hi David,

     

    Below is my new request as you formatted yours. Regarding the response, what does it means ? is it rights issue ?

     

     

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:obj="http://www.niku.com/xog/Object">
    <soapenv:Header>
    <obj:Auth>
    <obj:Username>myLogin</obj:Username>
    <obj:Password>myPassword</obj:Password>
    </obj:Auth>
    </soapenv:Header>
    <soapenv:Body>
    <obj:WriteTimeperiod>
    <NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_timeperiod.xsd">
    <Header version="6.0.11" action="write" objectType="timeperiod" externalSource="NIKU"/>
    <TimePeriods>
    <TimePeriod finish="2017-01-09T00:00:00" start="2017-01-01T00:00:00">
    <TimeSheets>
    <TimeSheet ID="5446018" resourceID="ResID" action="replace" status="1" version="6">
    <TimeSheetEntries>
    <TimeSheetEntry assignmentID="5225012" internalTaskID="5137006" projectID="PRJ_R&D" >
    <DailyActuals>
    <Actual actualDate="2017-01-01" amount="0"/>
    <Actual actualDate="2017-01-02" amount="0"/>
    <Actual actualDate="2017-01-03" amount="8"/>
    <Actual actualDate="2017-01-04" amount="8"/>
    <Actual actualDate="2017-01-05" amount="8"/>
    <Actual actualDate="2017-01-06" amount="8"/>
    <Actual actualDate="2017-01-07" amount="0"/>
    <Actual actualDate="2017-01-08" amount="0"/>
    </DailyActuals>
    </TimeSheetEntry>
    </TimeSheetEntries>
    </TimeSheet>
    </TimeSheets>
    </TimePeriod>
    </TimePeriods>
    </NikuDataBus>
    </obj:WriteTimeperiod>
    </soapenv:Body>
    </soapenv:Envelope>

     

     

    ---------------Response

     

    <html><head><script>location.replace("/niku/app?action=union.externalError&c3RhdHVz=NDAz");</script></head></html>

     

     

    Thanks



  • 11.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 06, 2017 12:21 PM

    Doesn't mean much to me - that looks like you maybe aren't sending the request to the right URL



  • 12.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 06, 2017 12:24 PM

    Testing with SOAPUI, the URL is the right



  • 13.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 06, 2017 12:38 PM

    That is not a XOG response, that is a webserver response.

    You were getting a XOG response earlier so you must be doing something different now; thats all I can tell.



  • 14.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 09, 2017 04:33 AM

    Hi David,

     

    I deleted manually timesheet entries in Clarity, then I could write/update timesheets, but  it's fails sometimes. 

    Instead of update the timesheets, I want to create it but I don't know how to get the assignmentID to make my write/create request :

    <TimeSheetEntry assignmentID="5225012" internalTaskID="5137006" projectID="PRJ_RD" > 

    I tryed to get it htrough project read, but there is no assignmentID in the response.

    Can somebody tell me where can I get assignmentID ? I know that for the TimeSheet ID I have to put "-1" , but I don't know for the assignmentID.

     

     

    Thanks



  • 15.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 09, 2017 04:43 AM

    If the resource is already assigned to the task, then you can read it from the database, if the resource is not assigned then I'm not sure, perhaps "-1" again (GUESSING), but you'll have to check whether the resource is assigned or not anyway.



  • 16.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 09, 2017 05:49 AM

    Yes, the resource is already assigned to the task and I able to see it in the database, in PRASSIGNMENT table with PRID (assignmentID) and PRTASKID (internalTaskID) columns. 

    Is it possible to read this table through XOG ? 

     

    I tryed "-1" but not working.

     

     

    Thanks



  • 17.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 09, 2017 06:01 AM

    The value might be somewhere in one of the standard XOG object reads (but you say you've trying the project read which is where I would look to start), however not XOG as such, but over SOAP we can call (any) querys - this is the "Query API", some info here ; Obtaining NSQL Query Output via XOG so could easily create a simple query to give you the ID from a project/task/resource (parameter) combination.



  • 18.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 09, 2017 10:39 AM

    Hi Dave,

    I built my NSQL in Clarity, and was able to XOG through direct XOG, but I don't know how to make my SOAP request, need help please ! 

     

    <?xml version="1.0" encoding="UTF-8"?>
    <Query xmlns="http://www.niku.com/xog/Query">
    <Code>xtd_AssignmtIDR</Code>
    <Filter>
    <param_taskid>5126000</param_taskid>
    </Filter>
    </Query>

     

     

    Thanks



  • 19.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 09, 2017 10:50 AM

    The query API call is not a XOG call quite in the same way as the "NikuDataBus" stuff (some of the terminology in that other thread is a bit misleading I think), its just a SOAP call - you should just be all to send it (wrapped in a SOAP envelope) to the same URL you send a XOG request to though.



  • 20.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 09, 2017 11:39 AM

    I have this SOAP response  from server, I don't know what is wrong in my SOAP

     

    ------------------------- REQUEST 

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:quer="http://www.niku.com/xog/Query">
    <soapenv:Header>
    <quer:Auth>
    <obj:Username>Login</obj:Username>
    <obj:Password>Password</obj:Password>
    </quer:Auth>
    </soapenv:Header>
    <soapenv:Body>
    <Query xmlns="http://www.niku.com/xog/Query">
    <Code>xtd_AssignmtIDR</Code>
    <Filter>
    <param_taskid>5126000</param_taskid>
    </Filter>
    </Query>
    </soapenv:Body>
    </soapenv:Envelope>

     

    ---------------------------- RESPONSE

    HTTP/1.1 403 Forbidden
    Content-Type: text/html;charset=utf-8
    Content-Length: 114
    Date: Mon, 09 Jan 2017 16:33:24 GMT
    Server: CA PPM

     

    <html><head><script>location.replace("/niku/app?action=union.externalError&c3RhdHVz=NDAz");</script></head></html>



  • 21.  Re: SOAP request fails when trying to Write Timesheet
    Best Answer

    Posted Jan 09, 2017 11:49 AM

    Check you are sending it to the right URL (should be the application's URL with /niku/xog at the end).

     

    Also this bit looks odd;

    <quer:Auth>
    <obj:Username>Login</obj:Username>
    <obj:Password>Password</obj:Password>
    </quer:Auth>

     

    should be 

    <quer:Auth>
    <quer:Username>Login</quer:Username>
    <quer:Password>Password</quer:Password>
    </quer:Auth>

    I think.

     

    (incidentally, if you have already logged into the application in your code, then you should provide the session id token in place of the user and password, just to save creating multiple new sessions in the application



  • 22.  Re: SOAP request fails when trying to Write Timesheet

    Posted Jan 09, 2017 11:58 AM

    It's working !

    Thanks a lot David