Update tasks fields from request additional field - again :)

Update tasks fields from request additional field - again :)

I need to automatically complete the task fields with the start and end date based on an additional field in the request. I have the following script but it doesn't work properly. After launching, it throws the error "{"result":"Failure","message":"Task fetch failed"}" Please help me because I'm out of ideas :)

SDP MSP 14.000
technician key is configured :)

  1. configuration = global_function_10();
    dateOfJoining = "udf_date_904";

    helpdeskID = context.get("instance").get("id");
    workorderid = requestObj.get('id');
    json_data = {"list_info": { "row_count": "100"} };

    taskresponse = invokeurl
    [
        url: configuration.get('url') + "/api/v3/requests/"+workorderid+"/tasks"
        type: GET
        headers: {"authtoken":configuration.get("technicianKey"),"PORTALID":helpdeskID}
        parameters: {"input_data":json_data}
    ];
    successList = List();
    failureList = List();
    resultantJson = Map();

    schedule_end_date = requestObj.get("udf_fields").get(dateOfJoining).get("value");
    additionalField = requestObj.get("udf_fields").get(dateOfJoining).get("display_value").toDateTime();
    additionalField = additionalField.subDay(7);
    schedule_start_date = additionalField.toString().unixEpoch("Asia/Calcutta");

    info schedule_start_date;

    if("success".equalsIgnoreCase(taskresponse.get("response_status").get("status")))
    {
        taskData = taskresponse.get('tasks');
        for each task in taskData{
            input_data = {
                    "task": {
                            "scheduled_start_time": {"value":schedule_start_date },
                            "scheduled_end_time": {"value":schedule_end_date }
                            }
                        };

            response = invokeurl
            [
                url: configuration.get('url') + "/api/v3/requests/"+workorderid+"/tasks/" + task.get("id")
                type: PUT
                headers: {"authtoken":configuration.get("technicianKey"),"PORTALID":helpdeskID}
                parameters: {"input_data":input_data}
            ];

            if("success".equalsIgnoreCase(response.get("response_status").get("status")) ){
                successList.add(task.get('id'));
            }
            else{
                failureList.add(task.get('id'));
            }
        }
        msg = "";
        if(!successList.isEmpty()){
            msg = "List of Tasks successfully edited: " + successList;
        }
        if(!failureList.isEmpty()){
            msg = msg + ",   List of Tasks failed to Edit: " +failureList;
        }
        resultantJson.insert("result": "Success","message": msg);
    }
    else{
        resultantJson.insert("result": "Failure","message": "Task fetch failed");
    }
    return resultantJson;

                New to ADSelfService Plus?