ProxymanApp / ProxymanApp/Proxyman

Scripts that assign the JSON response.body to true fail

Open
#1,024 4 comments 0 reactions 1 assignee View on GitHub

@NghiaTranUIT is already working on this.

Since Oct 12, 2021.

✅ Done bug
Dominant language
No language data
Stars
7k
Forks
237
PR merge metrics
No merged PRs in 30d

Description

Scripts that assign the response.body to true fail with an error (see below for error details).

If I wrap the true literal in a JSON object, it works. However, true is valid JSON, and many JSON APIs return only boolean literals.

Here's the full script I'm using:

function onResponse(context, url, request, response) {
  response.body = true;
  response.headers["Content-Type"] = "application/json"
  response.statusCode = 200
  return response;
}
Proxyman version

2.33.0 (23300)

macOS Version

11.6 (20G165)

Steps to reproduce
  1. Create a script
  2. Enter the script content above
  3. Save and activate it
  4. Exercise the script by requesting the endpoint
Expected behavior

The response body is true

Actual behavior

An error is reported:

❌Error: Invalid Body JSON Object. Please verify the body is a valid JSON. (Content-Type=application/json)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.