objectscript / EnsembleWorkflow

Restful web API for InterSystems Ensemble Workflow
MIT License
2 stars 4 forks source link

set tTaskResponce = %request.Content.Task Raises Property Does Not Exist #3

Closed railrhoad closed 7 years ago

railrhoad commented 7 years ago

Located within PostTask, we're getting a PropertyDNE on *Task. We have the other service behaving as expected in our REST client but we're now at the point where we'd like to perform updates.

{
    "errors":[ {
            "code":5002,
            "domain":"%ObjectErrors",
            "error":"ERROR #5002: Cache error: <PROPERTY DOES NOT EXIST>zPostTask+5^eReferral.REST.Services.1 *Task,%CSP.BinaryStream",
            "id":"CacheError",
            "params":["<PROPERTY DOES NOT EXIST>zPostTask+5^eReferral.REST.Services.1 *Task,%CSP.BinaryStream"
            ]
        }
    ],
    "summary":"ERROR #5002: Cache error: <PROPERTY DOES NOT EXIST>zPostTask+5^eReferral.REST.Services.1 *Task,%CSP.BinaryStream"
}

%request.Content is a CSP.BinaryStream, what I don't understand is how %request.Content.Task gets populated. I can understand what's getting passed in will directly influence the Content but I don't even see how this Task serialization happens within the service (as I try to debug this).

Here's my input to the service which is JSON valid and appears to be schema valid based on the sample input provided in the readme:

{
    "_class": "EnsLib.Workflow.Worklist",
    "_id": "1208||ereferraladmin",
    "Task": {
        "_class": "EnsLib.Workflow.TaskResponse",
        "_id": 1208,
        "%Action": "$Accept",
        "%Priority": 3,
        "%UserName": "",
        "%UserTitle": "",
        "%UserRanking": "",
        "%RoleName": "eReferral.WF.ClinicianReview",
        "%Subject": "Clinician review required for referral 12",
        "%Message": "Some sample message",
        "%Actions": "Reviewed,Return",
        "%FormTemplate": "",
        "%FormFields": "Comments",
        "%FormValues": {

        },
        "%Status": "Unassigned",
        "%TaskStatus": {
            "_class": "EnsLib.Workflow.TaskStatus",
            "Role": {
                "_class": "EnsLib.Workflow.RoleDefinition",
                "_id": "eReferral.WF.ClinicianReview",
                "Name": "eReferral.WF.ClinicianReview",
                "Description": "",
                "Capacity": 100
            },
            "AssignedTo": "",
            "TimeCreated": "2017-03-15 14:17:00.463",
            "TimeCompleted": "",
            "SessionId": 1563,
            "Source": "EnsLib.Testing.Process",
            "ResponseToken": "1564|EREFERRALPKG.EdgeGatewayProduction",
            "IsComplete": false,
            "Request": {
                "_class": "EnsLib.Workflow.TaskRequest",
                "_id": 1206,
                "%Actions": "Reviewed,Return",
                "%Subject": "Clinician review required for referral 12",
                "%Message": "Some sample message",
                "%Priority": 3,
                "%UserName": "",
                "%Title": "",
                "%TaskHandler": "",
                "%Command": "",
                "%FormTemplate": "",
                "%FormFields": "Comments",
                "%FormValues": {

                }
            }
        }
    },
    "User": {
        "_class": "EnsLib.Workflow.UserDefinition",
        "_id": "ereferraladmin",
        "Name": "ereferraladmin",
        "FullName": "ereferral admin",
        "IsActive": true
    },
    "Role": null,
    "TimeCreated": "2017-03-15 14:17:00.465",
    "IsNew": true,
    "Age": "00w 0d 01h 08m 47s"
}
railrhoad commented 7 years ago

I even passed in the JSON from the readme (which I knew wouldn't find the task referenced) but it failed in the same place before it could even look it up.

eduard93 commented 7 years ago

You're getting an error here because %request.Content is %CSP.BinaryStream but EnsLib.Workflow.Worklist is expected. Conversion from %CSP.BinaryStream is done in ConvertRequestBody. Seems like it's not hit for you.

Please provide:

1.$zv

  1. Does adding do ..ConvertRequestBody() before set tTaskResponce = %request.Content.Task and recompiling helps?
  2. Does Workflow.AbstractREST compile without problems?
railrhoad commented 7 years ago

You're exactly right! I was cherry picking into my preexisting service and simply missed this line. Sorry for the noise and thanks for the quick response!