Return a plain text response to an HTTP or SDK request

Return a plain text response to an HTTP or SDK request

A user recently reached out for help with an HTTP integration that required a response with a content-type of text/plain.

Luckily, Pipedream makes it easy to return a custom response to any HTTP or SDK triggered event using $respond(). You get code level control over the status code, headers and body returned for any HTTP or SDK event.

For this specific use case, we set the content-type header to text/plain and returned the message export from steps.export_example (step exports are how you pass data between steps of your workflow):

$respond({
  immediate: true,
  status: 200,
  headers: { "content-type": "text/plain" },
  body: steps.export_example.message
});

Loading the URL that triggers the workflow returns the custom message we defined with the content-type set to text/plain:

Check out the code here — you can copy and run it for free!

https://pipedream.com/@/return-a-plain-text-http-response-p_5VC1Vj

Note: Pipedream will automatically generate a unique URL to trigger your code when you copy and deploy it in your account.

You can also see the workflow in action here:

Check out Pipedream's docs to learn more about $respond() at https://docs.pipedream.com/workflows/steps/triggers/#http-responses