Chris
Chris5w ago

Formatting Workflow Output in API Call Trigger and setting HTTP Status Code

How do I switch my account back to the V1 builder? I need to be able to set http status codes on api trigger responses and it seems like this isn't possible on Flow Builder 2.0
Solution:
oh, the Workflow output section you see in the image only kicks in at the end of a workflow execution. So, in your case for instance, you can add two output properties to the output node of your workflow (image 1). Then, in the workflow output section of your trigger, you can pick these properties and assign them to Response Body and Status Code (image 2)...
No description
No description
Jump to solution
25 Replies
AI Support
AI Support5w ago
AI Support Bot Information
<@1193313198183550978> you can react on the relevant answer (message) with a ✅ in this thread when you think it has been solved, by the bot or by a human! Anyone can react on this message with a ❌ if the GPT bot is unhelpful or hallucinating answers. Please note: Team members will review and answer the questions on best efforts basis.
AI Support
AI Support5w ago
AI Response
I'm unable to find specific instructions on how to switch back to the V1 Builder or set HTTP status codes directly from the provided files. However, I recommend visiting the BuildShip community on Discord, where you can join the #FeatureRequest channel to discuss this issue. You can browse other feature requests and cast your votes, or even submit your request to see if there's support for it within the community. If this doesn't help, consider reaching out to BuildShip support via the Support button on your BuildShip Dashboard for more personalized assistance【4:0†buildship-docs.json】.
BuildShip AI Support
nithinrdy
nithinrdy5w ago
Hey @Chris , it's certainly possible to set a status code on your workflow's http responses. To start with: - Add a REST API Call trigger to your workflow. - Configure the Path, Method and Request Type on the Setup tab of the trigger, and then hit "Connect". - After the trigger is done connecting, you should now be able to see a few additional fields appear under the existing ones. The last two of these are the response body and the status code. By default, the response body is the entire flow output, and the status code is 200. You can configure both these values using the expression editor option next to these fields (for example, if you want the response body to only contain a specific property of the output, not the entire thing, or if you want the status to change based on the flow output, stuff like that) Image for reference.
No description
Chris
ChrisOP5w ago
Yeah but how do I do this at the end of a workflow though? Setting it at the REST API Call trigger is too soon I want to be able run through my workflow first and set the http status code at the end.
Solution
nithinrdy
nithinrdy5w ago
oh, the Workflow output section you see in the image only kicks in at the end of a workflow execution. So, in your case for instance, you can add two output properties to the output node of your workflow (image 1). Then, in the workflow output section of your trigger, you can pick these properties and assign them to Response Body and Status Code (image 2)
No description
No description
nithinrdy
nithinrdy5w ago
In other words, the workflow output section of a trigger acts as one final step (that runs after the workflow's output node, and before sending back the response). The section lets you format the workflow's output (pick and choose which properties you want to send back, and so on).
Chris
ChrisOP5w ago
Oh okay. I think I got it, let me try this. Thanks for the help
Chris
ChrisOP5w ago
It isn't working. I'm able to get the raw output of my workflow but I'm not able to parse it to get the status code or underlying response. Here is what I have:
No description
Chris
ChrisOP5w ago
I want to extract the statusCode to set directly and then use the remaining attributes as the response. But I just get a 500 for the api and an empty object as response If I set Flow Output directly, it works
nithinrdy
nithinrdy5w ago
The flow output is, by default, an object. You shouldn't need to parse it, and should be able to destructure the flow output directly, sorta like so:
const {statusCode, ...response } = flowOutput
return response
const {statusCode, ...response } = flowOutput
return response
and then flowOutput.statusCode for your status code.
Chris
ChrisOP5w ago
I'm passing a string as my output in the output node
No description
Chris
ChrisOP5w ago
If I try to destructure directly I get this response
No description
Chris
ChrisOP5w ago
Is this correct?
No description
nithinrdy
nithinrdy5w ago
Ah, in this case you'd need to parse the output property within the flow output, since the string you're trying to parse is assigned to the output property within the flow output are you able the select the Output variable inside the Flow Output variable, from the variables menu? If so try parsing that.
nithinrdy
nithinrdy5w ago
No description
nithinrdy
nithinrdy5w ago
You could also try doing
No description
Chris
ChrisOP5w ago
That doesn't work either. Also this returns string in the api response
No description
Chris
ChrisOP5w ago
However this returns an empty object
No description
Chris
ChrisOP5w ago
I can try returning an object from my output node if that is easier / it's intended use
nithinrdy
nithinrdy5w ago
ah, i think i see the issue. in your json string, you've got a colon instead of a comma after "error" Could that be the reason? Right, it would certainly be easier to separate the output into two properties. So one for status code, one for the response body. Then you can simply select these variables in their respective fields in the workflow output section.
Chris
ChrisOP5w ago
Ah yes that might have been the issue. Is there any logging for the Output response script in the API Call trigger? In any case I switched to setting different properties for the Output node and it works now Thank you for the help
nithinrdy
nithinrdy5w ago
You should be able to see output logs in the workflow logs section, it should be the last entry for every workflow log (assuming the workflow contains an output node).
Chris
ChrisOP5w ago
The last log is the output node but I want to see logs for the API Call trigger. So in the event there is an error (like incorrect JSON parse) I would see it.
nithinrdy
nithinrdy5w ago
Hmm, I see what you mean. In the workflow logs, you should find an entry that's just a random id string (UI requires a bit of improvement), instead of a node label. That's the only place I can think of that would contain trigger related logs (the id is that of a trigger). Either way, I'll see if this can be improved. No problem! I'm not sure if discord allows it, but could you please edit the title of this thread to something like "Formatting the Workflow Output", should allow other users to stumble across this thread if they're facing the same issue.
Chris
ChrisOP5w ago
I see the random Id string, but it's not expandable so I don't see any additional logs. In any case I should have everything I need to proceed. Thanks again