ハマったので備忘。
APIにJSON渡して、戻ってきたJSONを受け取ってまたゴニョゴニョしたいときなどに。
var client = test.openHttpClient();
client.setFollowRedirects(false);
test.beginTransaction();
test.beginStep("Step-001");
// Request
var url = 'https://example.com/api/getName';
var request = client.newPost(url);
request.addRequestHeader("Content-Type", "application/x-www-form-urlencoded");
var json = {
id:'hoge'
};
var strJson = JSON.stringify(json);
request.setRequestBody(strJson);
// Response
var response = request.execute();
var code = response.getStatusCode();
test.log(code);
var body = response.getBody();
test.log(body);
var obj = JSON.parse(body)
test.log(obj.name);
test.endStep();
test.endTransaction();