EN
Español
English
Português
    Order Creation

    The related operation for creating work orders is described.

    Details of the request:

    • Base URL: {host}/AFLSAPI/
    • URI: api/workorders
    • Type: POST

    • Required headings:

    • Content-Type: application/json
    • X-Authorization: Bearer {Token}

    URL Description

    • {host}: It represents the domain of the environment in which the API is located.
    • AFLSAPI/: Fixed API prefix.
    • URI: Specific endpoint for the request.


    EXAMPLE URL:

    https://{host}/AFLSAPI/api/workorders 
    


    Parameters:

    Name Data type Obligatory Description
    addressContact String Yes Contact address
    addressContactInfo String No Contact Address Information
    assignmentType Integer No Assignment Type
    clientId Integer Yes Customer ID
    companyId Integer No Company ID
    contactEmail String No Contact email
    contactLatitude number - double Yes Latitude of address contact
    contactLongitude number - double Yes Contact Direction Length
    contactName String Yes Contact Name
    contactPhone String No Contact telephone number
    creatorId Integer No Work Order Creator User ID
    Description String Yes Work Order Description
    endAddress String No Final address
    endAddressInfo String No Final Address Information
    endLatitude number - double No End Address Latitude
    endLongitude number - double No Final Address Length
    Id Integer No Id de la WorkOrder
    priority Integer Yes Priority Type: 0 - Normal, 1 - Emergency, 2 - Priority
    providerId Integer No Provider ID
    serviceId Integer Yes Service associated with the order
    specialistId Integer No Id of the attending specialist
    state Integer Yes Order Status - Value Only: 1
    subject String Yes Subject or title of the order
    subStateId Integer No Sub Estate
    ticketId String No Order Ticket
    attentionEndDate string - datetime No End of Care Date
    attentionStartDate string - datetime No Start of Care Date
    tentativeAttentionEndDate string - datetime No Tentative End of Care Date
    tentativeAttentionStartDate string - datetime No Date of Attention Tentative
    tentativeTravelStartDate string - datetime No Travel Start Date
    travelStartDate string - datetime No Travel Start Date
    additionalFields Array No List additional fields
    attachments Array No List of attachments
    Products Array No List products for service
    workTasks Array No Work order task list

    Body of the petition:

    The request consists of a JSON object. Example:

    {
        "addressContact": "Calle 39B, Teusaquillo, 11311 Teusaquillo, Distrito Capital, Colombia",
        "addressContactInfo": "",
        "clientId": 24,
        "companyId": null,
        "contactEmail": "tati@pruebas.com",
        "contactLatitude": 4.629124230469785,
        "contactLongitude": -74.0730822280432,
        "contactName": "Cración de Ordenes con campos adicionales",
        "contactPhone": null,
        "description": "Cración de Ordenes con campos adicionales API WORKORDER",
        "endAddress": "",
        "endAddressInfo": "",
        "endLatitude": 0,
        "endLongitude": 0,
        "id": 0,
        "priority": 0,
        "serviceId": 36,
        "state": 1,
        "subject": "Cración de Ordenes con campos adicionales",
        "subStateId": 1,
        "attentionEndDate": "",
        "attentionStartDate": "",
        "tentativeAttentionEndDate": "",
        "tentativeAttentionStartDate": "",
        "tentativeTravelStartDate": "",
        "travelStartDate": "",
        "additionalFields": [
            {
                "id": 24,
                "value": "3"
            },
            {
                "id": 24,
                "value": "Esta son unas pruebas para campo adicional tipo parrafo"
            }
        ],
        "products": [
            {
                "cost": 0,
                "description": "",
                "id": 0,
                "isActive": true,
                "name": "",
                "productId": 4,
                "quantity": 1,
                "sku": "",
                "typeProduct": 0
            }
        ],
        "workTasks": null
    }
    

    Answer:

    As an answer, a JSON object is obtained, with the following information:

     {
        "addressContact": "Floresta Outlet, Carrera 69, Santa Rosa, 11121 Suba, Distrito Capital, Colombia",
        "addressContactInfo": "Piso 7",
        "assignmentType": 0,
        "clientId": 213,
        "companyId": null,
        "contactEmail": "tati@pruebas.com",
        "contactLatitude": 4.6919158,
        "contactLongitude": -74.0745394,
        "contactName": "PRUEBAS CREACIÓN DE ORDENES DESDE LA API DE WORKORDERS",
        "contactPhone": "30122222222",
        "creatorId": 3,
        "description": "PRUEBAS CREACIÓN DE ORDENES DESDE LA API DE WORKORDERS",
        "endAddress": null,
        "endAddressInfo": "",
        "endLatitude": 0.0,
        "endLongitude": 0.0,
        "id": 87,
        "priority": 1,
        "providerId": 2,
        "serviceId": 1,
        "specialistId": 11,
        "state": 1,
        "subject": "Pruebas de Creación de orden de Emergencia",
        "subStateId": 10,
        "ticketId": "87",
        "attentionEndDate": null,
        "attentionStartDate": null,
        "tentativeAttentionEndDate": "2024-03-20T01:12:27.079+00:00",
        "tentativeAttentionStartDate": "2024-03-19T22:12:27.079+00:00",
        "tentativeTravelStartDate": "2024-03-19T22:12:27.079+00:00",
        "travelStartDate": null,
        "additionalFields": [
            {
                "actions": null,
                "definitionId": 1,
                "description": null,
                "formatValidator": null,
                "helpMessage": "Campo orden simple",
                "id": 4,
                "itemId": 0,
                "keepHistory": false,
                "label": "Campo orden simple",
                "name": "ca-campo orden simple-1",
                "options": null,
                "order": 1,
                "permissions": [
                    {
                        "statusId": 7,
                        "name": "General",
                        "roles": [
                            {
                                "actions": {
                                    "edit": true,
                                    "required": false,
                                    "view": true
                                },
                                "id": 276,
                                "name": "AFLS_Dispatcher"
                            },
                            {
                                "actions": {
                                    "edit": true,
                                    "required": false,
                                    "view": true
                                },
                                "id": 278,
                                "name": "AFLS_Monitor"
                            }
                        ]
                    }
                ],
                "state": null,
                "status": true,
                "typeId": 1,
                "value": null
            }
        ],
        "attachments": [
            {
                "createDate": "2024-03-19T22:24:37.607+00:00",
                "description": null,
                "fileExtension": "pdf",
                "filePath": null,
                "fileSize": "182848",
                "id": 6,
                "realFileName": "PRUEBA",
                "serveFileName": null
            }
        ],
        "products": [
            {
                "cost": 10000.00,
                "description": "Cable",
                "id": 11,
                "isActive": true,
                "name": "Cable",
                "productId": 1,
                "quantity": 2,
                "sku": "001",
                "typeProduct": 0
            }
        ],
        "workTasks": null
    }
    

    Error messages:

    Code HTTP status Error Message
    400 BadRequest ServiceId not related to clientId
    400 BadRequest ProductId x not found.
    400 BadRequest AdditionalField x not found.
    400 BadRequest ClientId is not valid.
    400 BadRequest Client x is inactive
    400 BadRequest Standard Service does not require EndAddress, EndLatitude or EndLongitude.
    400 BadRequest Service x is inactive.
    400 BadRequest AssignmentType not found.
    400 BadRequest SpecialistId not found.
    400 BadRequest WorkOrder State is not valid.
    400 BadRequest EndAddress, EndLatitude and EndLongitude are required.
    400 BadRequest AddressContact, ContactLatitude and ContactLongitude are required.
    401 Unauthorized Authorization has been denied for this request.
    500 Internal Server Error FailureLogin