Is the `body` of the `Request` class working? (Empty despite being set?)

In a script I’m making a Request with this body:

request.body = { "userName": "myUsername", "password": "myPassword" }

When I output the request using console.log I indeed see this:

..., "body: {"password":"myPassword", "userName":"myUsername"}, ...

However, when performing the request the server returns a 503. When I inspect the actual communication with Charles Proxy for iOS the request body is entirely empty…

@simonbs Is this a bug / known issue?

I have this behaviour with the App Store release and the latest beta

what’s your request.method?

request.method = "POST"

Oops. Just remembered this:

Actually in this case that did not seem to help, but just using a string did:

request.body = "userName=" + username + "&password=" + password

I tried to inline it like this, but that did not work:

request.body = "userName=${username}&password=${password}"

Does Scriptable support inlining variables? How?

Try using back ticks for string wrapping with inline variables.

3 Likes