Custom App returns a FileResult - Error

@Matronix I assume you have solved it within the last year :smiley:

But today I ran into the same issue of receiving the following error while building a custom App.
“The operation failed with an error. Invalid module output. Expected Object, but found Uint8Array.”
The communication response looked like this:

    "response": {
        "output": "{{body}}"
    }

I quickly wanted to share my solution in case others encounter it as well. Note: If there is a part which does not go in line with best-practices, I’d be happy to know how it’s done correctly! :slight_smile:
This way it works:

    "response": {
        "output": {
            "data": "{{body}}"
        } 
    }

My interface looks like this:

    {
        "name": "data",
        "type": "buffer",
        "label": "Data",
        "semantic": "file:data"
    }

This way I am able to get the data and process it further!

1 Like

Hi Richard,

Possibly, your module is expecting a JSON response.
Could you try specifying the response type by adding "type": "binary" to the response

"response": {
        "type": "binary",
        "output": {
            "data": "{{body}}"
        } 
    }

If that doesn’t work, you may also try to use the toBinary() function:

"response": {
        "type": "binary",
        "output": {
            "data": "{{toBinary(body)}}"
        } 
    }
3 Likes

Hi @Thomas_Gaillard,

thank you so much! I’ll add the “type”:“binary” to my response.

Sorry for any confusion, the response with “data”:“{{body}}” was already working on my end. I just wanted to share a solution as I was looking for one and the linked thread didn’t get to a solution.

I was thinking that maybe some day someone else will be running into the mentioned error and might be happy to find this thread :smiley:

Best,
Richard

4 Likes