Forum Academy Marketplace Showcase Pricing Features

API Help - How to send "/n" without converting to literal characters?

I am trying to use PythonAnywhere’s API to ‘type’ to a virtual console I have created there in order to execute a python script.

As such, I am using a POST command with " /api/v0/user/{username}/consoles/{id}/send_input/"

in order to send “input” as my key and “python” as the value. Doing so successfully sends that text to the console. However, I cannot actually get it to execute on the console (Ie. the part where you would simply hit enter). The folks at PythonAnywhere told me I need to include “\n” at the end of that string. However, doing so simply sends the literal text “python\n” to the console.

So basically I am wondering how to have Bubble / the API connector send “/n” as a new line, not as the literal individual characters?

Thanks a lot in advance.

I believe a \n equates to ASCii hex value A0 (decimal value of 10).
Did not test this
You could try append: arbitrary text then enter {ALT} 10, using the ALT key and entering 10 on the numeric keypad. This might append the hex AO (decimal 10). The result character you see should look funny, I got a little square like thing. If you see 10 when you type it in then it is not taking the ALT code. FYI- you have to hold the ALT key down when doing the 10 (sorry you likely know this, but others may find it helpful info).

Thanks a lot for the reply. This makes sense but I think Bubble / API connecter did the same thing and just converted it to the symbol which then also showed up in the console lol:

I also tried this in the body section:

“input”: “python◙”
and got this as a response:

**Raw response for the API **
Status code 415
{“detail”:“Unsupported media type “” in request.”}

Did you try :format as... with transforming the text to be the text plus a literal line break? (like, literally hit return in the format box)

I actually just figured it out:

I set Body Type to “Raw”, added a header for “Content-Type” value = “application/json”

and set the body to be simply: “{“input”:“echo hello\n”}”

1 Like

There ya go.

yes, thanks a lot for your suggestion, will probably need it when I start adding more functionality

1 Like