How to serve content-type as plain text


I attempted to return plain text content in Cloud Code. However, It seems to return as a JSON-escaped string.

In fact, this was only the first step into trying to set up icalendar content. So eventually I would like to return “text/calendar” content, but first I tried “text/plain” and I do not seem to be getting anywhere.

Here is what I have “coded” in Codeless:

The response when invoked seems OK:

However, when called in the browser, here is the response:


Note the extra " at the very beginning and the very end, as well as the escaped newline characters.

Wondering if it was the request which was wrong, I tried modifying the Accept and Content-Type parameters, but nothing changed :

So I’m guessing there is somewhere I need to set up the Cloud Code API route so as to simply return the Codeless string output, without JSON-escaping it. I haven’t found anything in the documentation or support forums.

Could someone point me in the right direction please ? Thanks !

Hello @Nicolas_REMY

It’s ok.
" is not a symbol of response
Length of “asd” is 3, you can test it


Hi @viktor.liablin and thank you for your reply.
However, I am afraid I don’t understand it. Could you please explain how the length is related to the fact that the string is escaped ?

Hello @Nicolas_REMY

Try to setup a response header content-type:text/plain

Regards, Vlad

1 Like

Wonderful ! That was the part I had been missing. I had overlooked that “Response Headers” block, which was hidden at the right !
Thank you @vladimir-upirov