[GH-ISSUE #955] Script Error: Could not parse the body as Plain-Text. (Content-Type=text/html; charset=utf-8) #950

Open
opened 2026-03-03 19:23:17 +03:00 by kerem · 15 comments
Owner

Originally created by @phoenix5980 on GitHub (Aug 4, 2021).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/955

Originally assigned to: @NghiaTranUIT on GitHub.

Proxyman version? (Ex. Proxyman 1.4.3)

Version 2.30.0

macOS Version? (Ex. mac 10.14)

11.4

Steps to reproduce

function onResponse(context, url, request, response) {
var bodyStr = response.body;
var decodeBody = atob(bodyStr);
var jsonBody = JSON.parse(decodeBody);
var counter = jsonBody["count"];
counter = counter + 1;
console.log(counter);
var jsonBody["count"] = counter;
var jsonStr= JSON.stringify(jsonBody);
var jsonEncode = btoa(jsonStr);
console.log(jsonEncode);
response.body = jsonEncode;
return response;
}

Expected behavior

In the last step, it should base64 encode the json string and send it to the client, but the log shows null for json.Encode and throws the following error:
❌Error: Could not parse the body as Plain-Text. (Content-Type=text/html; charset=utf-8)

Screenshots (optional)

Originally created by @phoenix5980 on GitHub (Aug 4, 2021). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/955 Originally assigned to: @NghiaTranUIT on GitHub. ### Proxyman version? (Ex. Proxyman 1.4.3) Version 2.30.0 ### macOS Version? (Ex. mac 10.14) 11.4 ### Steps to reproduce function onResponse(context, url, request, response) { var bodyStr = response.body; var decodeBody = atob(bodyStr); var jsonBody = JSON.parse(decodeBody); var counter = jsonBody["count"]; counter = counter + 1; console.log(counter); var jsonBody["count"] = counter; var jsonStr= JSON.stringify(jsonBody); var jsonEncode = btoa(jsonStr); console.log(jsonEncode); response.body = jsonEncode; return response; } ### Expected behavior In the last step, it should base64 encode the json string and send it to the client, but the log shows null for json.Encode and throws the following error: `❌Error: Could not parse the body as Plain-Text. (Content-Type=text/html; charset=utf-8)` ### Screenshots (optional)
Author
Owner

@NghiaTranUIT commented on GitHub (Aug 5, 2021):

hey @phoenix5980 look like your code is incorrect?

var bodyStr = response.body;
var decodeBody = atob(bodyStr);
var jsonBody = JSON.parse(decodeBody);
var counter = jsonBody["count"];
counter = counter + 1;
console.log(counter);
var jsonBody["count"] = counter;
var jsonStr= JSON.stringify(jsonBody);
var jsonEncode = btoa(jsonStr);

console.log(jsonEncode) // => null

As you mention, jsonEncoded is null. As a result, when you pass it to response.body, it causes the error.


If you're going to use atob, or btoa, please include the addon. The reason is JavascriptCore from WebKit framework doesn't have built-in atob, btoa, window function. (Snippet code: https://docs.proxyman.io/scripting/snippet-code#use-base64-addon)

// Encode Base64
const { btoa } = require("@addons/Base64.js")

// Usage:
var text = "HelloWorld";
var encodedText = btoa(text);
// Decode Base64
const { atob } = require("@addons/Base64.js")

// Usage:
var text = atob("aGVsbG8=");
<!-- gh-comment-id:893112032 --> @NghiaTranUIT commented on GitHub (Aug 5, 2021): hey @phoenix5980 look like your code is incorrect? ```js var bodyStr = response.body; var decodeBody = atob(bodyStr); var jsonBody = JSON.parse(decodeBody); var counter = jsonBody["count"]; counter = counter + 1; console.log(counter); var jsonBody["count"] = counter; var jsonStr= JSON.stringify(jsonBody); var jsonEncode = btoa(jsonStr); console.log(jsonEncode) // => null ``` As you mention, jsonEncoded is `null`. As a result, when you pass it to `response.body`, it causes the error. ---------------- If you're going to use atob, or btoa, please include the addon. The reason is JavascriptCore from WebKit framework doesn't have built-in atob, btoa, window function. (Snippet code: https://docs.proxyman.io/scripting/snippet-code#use-base64-addon) ```js // Encode Base64 const { btoa } = require("@addons/Base64.js") // Usage: var text = "HelloWorld"; var encodedText = btoa(text); ``` ```js // Decode Base64 const { atob } = require("@addons/Base64.js") // Usage: var text = atob("aGVsbG8="); ```
Author
Owner

@phoenix5980 commented on GitHub (Aug 5, 2021):

hey @phoenix5980 look like your code is incorrect?

var bodyStr = response.body;
var decodeBody = atob(bodyStr);
var jsonBody = JSON.parse(decodeBody);
var counter = jsonBody["count"];
counter = counter + 1;
console.log(counter);
var jsonBody["count"] = counter;
var jsonStr= JSON.stringify(jsonBody);
var jsonEncode = btoa(jsonStr);

console.log(jsonEncode) // => null

As you mention, jsonEncoded is null. As a result, when you pass it to response.body, it causes the error.

If you're going to use atob, or btoa, please include the addon. The reason is JavascriptCore from WebKit framework doesn't have built-in atob, btoa, window function. (Snippet code: https://docs.proxyman.io/scripting/snippet-code#use-base64-addon)

// Encode Base64
const { btoa } = require("@addons/Base64.js")

// Usage:
var text = "HelloWorld";
var encodedText = btoa(text);
// Decode Base64
const { atob } = require("@addons/Base64.js")

// Usage:
var text = atob("aGVsbG8=");

Oh, sorry but I believe the problem wasn't that part. I did have the addon part but didn't included it in Steps to reproduce.
'// Decode Base64
const { atob } = require("@addons/Base64.js")
// Encode Base64
const { btoa } = require("@addons/Base64.js")'
I had it in the very beginning but forgot to paste it here. And I did use console.log to check decodeBody which was atob(bodyStr), and atob was definitely working. But btoa didn't work here. I'm not sure why.

<!-- gh-comment-id:893233020 --> @phoenix5980 commented on GitHub (Aug 5, 2021): > hey @phoenix5980 look like your code is incorrect? > > ```js > var bodyStr = response.body; > var decodeBody = atob(bodyStr); > var jsonBody = JSON.parse(decodeBody); > var counter = jsonBody["count"]; > counter = counter + 1; > console.log(counter); > var jsonBody["count"] = counter; > var jsonStr= JSON.stringify(jsonBody); > var jsonEncode = btoa(jsonStr); > > console.log(jsonEncode) // => null > ``` > > As you mention, jsonEncoded is `null`. As a result, when you pass it to `response.body`, it causes the error. > > If you're going to use atob, or btoa, please include the addon. The reason is JavascriptCore from WebKit framework doesn't have built-in atob, btoa, window function. (Snippet code: https://docs.proxyman.io/scripting/snippet-code#use-base64-addon) > > ```js > // Encode Base64 > const { btoa } = require("@addons/Base64.js") > > // Usage: > var text = "HelloWorld"; > var encodedText = btoa(text); > ``` > > ```js > // Decode Base64 > const { atob } = require("@addons/Base64.js") > > // Usage: > var text = atob("aGVsbG8="); > ``` Oh, sorry but I believe the problem wasn't that part. I did have the addon part but didn't included it in Steps to reproduce. '// Decode Base64 const { atob } = require("@addons/Base64.js") // Encode Base64 const { btoa } = require("@addons/Base64.js")' I had it in the very beginning but forgot to paste it here. And I did use console.log to check decodeBody which was atob(bodyStr), and atob was definitely working. But btoa didn't work here. I'm not sure why.
Author
Owner

@NghiaTranUIT commented on GitHub (Aug 6, 2021):

@phoenix5980 Can you log this variable?

console.log(jsonStr)
Screen Shot 2021-08-06 at 10 40 03

I've run a test and btoa() works fine


Look like your syntax is incorrect.

var jsonBody = JSON.parse(decodeBody);
var counter = jsonBody["count"];
counter = counter + 1;
console.log(counter);

var jsonBody["count"] = counter; // <---- Error here (Should not use var to define jsonBody again)

It should be (remove the var)

var jsonBody = JSON.parse(decodeBody);
var counter = jsonBody["count"];
counter = counter + 1;
console.log(counter);

jsonBody["count"] = counter;
<!-- gh-comment-id:893978300 --> @NghiaTranUIT commented on GitHub (Aug 6, 2021): @phoenix5980 Can you log this variable? ```js console.log(jsonStr) ``` <img width="1800" alt="Screen Shot 2021-08-06 at 10 40 03" src="https://user-images.githubusercontent.com/5878421/128452572-c20300d7-01f2-4a36-b3f4-9f4a7dd91806.png"> I've run a test and `btoa()` works fine -------------------------- Look like your syntax is incorrect. ```js var jsonBody = JSON.parse(decodeBody); var counter = jsonBody["count"]; counter = counter + 1; console.log(counter); var jsonBody["count"] = counter; // <---- Error here (Should not use var to define jsonBody again) ``` It should be (remove the var) ```js var jsonBody = JSON.parse(decodeBody); var counter = jsonBody["count"]; counter = counter + 1; console.log(counter); jsonBody["count"] = counter; ```
Author
Owner

@phoenix5980 commented on GitHub (Aug 6, 2021):

The actual log will be very long though. Please see attached.
Basically I'm trying to get the seed from the server, and make the seed plus 1 everytime client connected, then send the new seed to the client.
I used console.log() to check all parts of the script, the only problem is jsonEncode, which is Base64 Encoded jsonStr. While jsonStr, as you can see, is working. I wonder what happened to jsonEncode and why did it show 'null'.

<!-- gh-comment-id:894006838 --> @phoenix5980 commented on GitHub (Aug 6, 2021): The actual log will be very long though. Please see attached. Basically I'm trying to get the seed from the server, and make the seed plus 1 everytime client connected, then send the new seed to the client. I used console.log() to check all parts of the script, the only problem is jsonEncode, which is Base64 Encoded jsonStr. While jsonStr, as you can see, is working. I wonder what happened to jsonEncode and why did it show 'null'.
Author
Owner

@phoenix5980 commented on GitHub (Aug 16, 2021):

@NghiaTranUIT Hi, I used typeof() to check the type of jsonStr and jsonBody. Interestingly the type of jsonStr shows string, while jsonEncode, which is btoa(jsonStr), shows object.

<!-- gh-comment-id:899327683 --> @phoenix5980 commented on GitHub (Aug 16, 2021): @NghiaTranUIT Hi, I used typeof() to check the type of jsonStr and jsonBody. Interestingly the type of jsonStr shows string, while jsonEncode, which is btoa(jsonStr), shows object.
Author
Owner

@NghiaTranUIT commented on GitHub (Aug 16, 2021):

Hey @phoenix5980 I'm able to reproduce your issue. It looks like the jsonStr is too big, so btoa() is failed somehow. I'm fixing it now 👍

<!-- gh-comment-id:899362721 --> @NghiaTranUIT commented on GitHub (Aug 16, 2021): Hey @phoenix5980 I'm able to reproduce your issue. It looks like the jsonStr is too big, so `btoa()` is failed somehow. I'm fixing it now 👍
Author
Owner

@NghiaTranUIT commented on GitHub (Aug 16, 2021):

Hey @phoenix5980 I discovered a bug in btoa() function. It's failed if the input is large enough.

Please use base64Encode() function. It will work 👍

const { base64Encode } = require("@addons/Base64.js")
var jsonEncode = base64Encode(jsonStr);

Full code:

// Addons List: https://docs.proxyman.io/scripting/addons
const { sayHello } = require("@addons/HelloWorld.js");
// Decode Base64
const { atob } = require("@addons/Base64.js")
// Encode Base64
const { base64Encode } = require("@addons/Base64.js")
//reset counter
var counter = 0;

function onResponse(context, url, request, response) {
  counter = counter + 1;
  var bodyStr = response.body;
  //replace all "%3D" with "="
  if (bodyStr.endsWith("%3D%3D")) {
				bodyStr = bodyStr.substring(0,bodyStr.length - 6) + "=="; 
      console.log("%3D%3D");
  //console.log(bodyStr);
			} else if (bodyStr.endsWith("%3D")) {
				bodyStr = bodyStr.substring(0,bodyStr.length - 3) + "="; 
        console.log("%3D");
			}
  var decodeBody = atob(bodyStr);
  console.log(decodeBody);
  console.log("Base64 decode success");
  var jsonBody = JSON.parse(decodeBody);
  console.log("===jsonBody");
  console.log(jsonBody);
  var oriseed = jsonBody["cache"]["replaced"]["battle"][0]["seed"];
  console.log("===original seed");
  console.log(oriseed);
  var newseed = oriseed + counter;
  jsonBody["cache"]["replaced"] ["battle"] [0] ["seed"] = newseed;
  console.log("===newseed");
  console.log(newseed);
  var jsonStr= JSON.stringify(jsonBody);
  console.log("===jsonStr");
  console.log(jsonStr);

  // Fix here
  var jsonEncode = base64Encode(jsonStr);
  console.log("===jsonEncode");
  console.log(jsonEncode);
  response.body = jsonEncode;
  console.log("===response.body");
  console.log(response.body);
  return response;
}

Uploading Screen Shot 2021-08-16 at 17.07.40.png…

<!-- gh-comment-id:899389210 --> @NghiaTranUIT commented on GitHub (Aug 16, 2021): Hey @phoenix5980 I discovered a bug in `btoa()` function. It's failed if the input is large enough. Please use `base64Encode()` function. It will work 👍 ```js const { base64Encode } = require("@addons/Base64.js") var jsonEncode = base64Encode(jsonStr); ``` Full code: ```js // Addons List: https://docs.proxyman.io/scripting/addons const { sayHello } = require("@addons/HelloWorld.js"); // Decode Base64 const { atob } = require("@addons/Base64.js") // Encode Base64 const { base64Encode } = require("@addons/Base64.js") //reset counter var counter = 0; function onResponse(context, url, request, response) { counter = counter + 1; var bodyStr = response.body; //replace all "%3D" with "=" if (bodyStr.endsWith("%3D%3D")) { bodyStr = bodyStr.substring(0,bodyStr.length - 6) + "=="; console.log("%3D%3D"); //console.log(bodyStr); } else if (bodyStr.endsWith("%3D")) { bodyStr = bodyStr.substring(0,bodyStr.length - 3) + "="; console.log("%3D"); } var decodeBody = atob(bodyStr); console.log(decodeBody); console.log("Base64 decode success"); var jsonBody = JSON.parse(decodeBody); console.log("===jsonBody"); console.log(jsonBody); var oriseed = jsonBody["cache"]["replaced"]["battle"][0]["seed"]; console.log("===original seed"); console.log(oriseed); var newseed = oriseed + counter; jsonBody["cache"]["replaced"] ["battle"] [0] ["seed"] = newseed; console.log("===newseed"); console.log(newseed); var jsonStr= JSON.stringify(jsonBody); console.log("===jsonStr"); console.log(jsonStr); // Fix here var jsonEncode = base64Encode(jsonStr); console.log("===jsonEncode"); console.log(jsonEncode); response.body = jsonEncode; console.log("===response.body"); console.log(response.body); return response; } ``` ![Uploading Screen Shot 2021-08-16 at 17.07.40.png…]()
Author
Owner

@phoenix5980 commented on GitHub (Aug 16, 2021):

Hey @phoenix5980 I discovered a bug in btoa() function. It's failed if the input is large enough.

Please use base64Encode() function. It will work 👍

const { base64Encode } = require("@addons/Base64.js")
var jsonEncode = base64Encode(jsonStr);
Full code:

// Addons List: https://docs.proxyman.io/scripting/addons
const { sayHello } = require("@addons/HelloWorld.js");
// Decode Base64
const { atob } = require("@addons/Base64.js")
// Encode Base64
const { base64Encode } = require("@addons/Base64.js")
//reset counter
var counter = 0;

function onResponse(context, url, request, response) {
counter = counter + 1;
var bodyStr = response.body;
//replace all "%3D" with "="
if (bodyStr.endsWith("%3D%3D")) {
bodyStr = bodyStr.substring(0,bodyStr.length - 6) + "==";
console.log("%3D%3D");
//console.log(bodyStr);
} else if (bodyStr.endsWith("%3D")) {
bodyStr = bodyStr.substring(0,bodyStr.length - 3) + "=";
console.log("%3D");
}
var decodeBody = atob(bodyStr);
console.log(decodeBody);
console.log("Base64 decode success");
var jsonBody = JSON.parse(decodeBody);
console.log("===jsonBody");
console.log(jsonBody);
var oriseed = jsonBody["cache"]["replaced"]["battle"][0]["seed"];
console.log("===original seed");
console.log(oriseed);
var newseed = oriseed + counter;
jsonBody["cache"]["replaced"] ["battle"] [0] ["seed"] = newseed;
console.log("===newseed");
console.log(newseed);
var jsonStr= JSON.stringify(jsonBody);
console.log("===jsonStr");
console.log(jsonStr);

// Fix here
var jsonEncode = base64Encode(jsonStr);
console.log("===jsonEncode");
console.log(jsonEncode);
response.body = jsonEncode;
console.log("===response.body");
console.log(response.body);
return response;
}

Thanks, works like a charm.

<!-- gh-comment-id:899395084 --> @phoenix5980 commented on GitHub (Aug 16, 2021): > Hey @phoenix5980 I discovered a bug in btoa() function. It's failed if the input is large enough. > > Please use base64Encode() function. It will work 👍 > > const { base64Encode } = require("@addons/Base64.js") > var jsonEncode = base64Encode(jsonStr); > Full code: > > // Addons List: https://docs.proxyman.io/scripting/addons > const { sayHello } = require("@addons/HelloWorld.js"); > // Decode Base64 > const { atob } = require("@addons/Base64.js") > // Encode Base64 > const { base64Encode } = require("@addons/Base64.js") > //reset counter > var counter = 0; > > function onResponse(context, url, request, response) { > counter = counter + 1; > var bodyStr = response.body; > //replace all "%3D" with "=" > if (bodyStr.endsWith("%3D%3D")) { > bodyStr = bodyStr.substring(0,bodyStr.length - 6) + "=="; > console.log("%3D%3D"); > //console.log(bodyStr); > } else if (bodyStr.endsWith("%3D")) { > bodyStr = bodyStr.substring(0,bodyStr.length - 3) + "="; > console.log("%3D"); > } > var decodeBody = atob(bodyStr); > console.log(decodeBody); > console.log("Base64 decode success"); > var jsonBody = JSON.parse(decodeBody); > console.log("===jsonBody"); > console.log(jsonBody); > var oriseed = jsonBody["cache"]["replaced"]["battle"][0]["seed"]; > console.log("===original seed"); > console.log(oriseed); > var newseed = oriseed + counter; > jsonBody["cache"]["replaced"] ["battle"] [0] ["seed"] = newseed; > console.log("===newseed"); > console.log(newseed); > var jsonStr= JSON.stringify(jsonBody); > console.log("===jsonStr"); > console.log(jsonStr); > > // Fix here > var jsonEncode = base64Encode(jsonStr); > console.log("===jsonEncode"); > console.log(jsonEncode); > response.body = jsonEncode; > console.log("===response.body"); > console.log(response.body); > return response; > } Thanks, works like a charm.
Author
Owner

@NghiaTranUIT commented on GitHub (Aug 16, 2021):

Fixed on this beta build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.31.0_Fix_btoa_bug.dmg

<!-- gh-comment-id:899490675 --> @NghiaTranUIT commented on GitHub (Aug 16, 2021): Fixed on this beta build: https://proxyman.s3.us-east-2.amazonaws.com/beta/Proxyman_2.31.0_Fix_btoa_bug.dmg
Author
Owner

@phoenix5980 commented on GitHub (Nov 2, 2021):

I have to reopen the issue since I encountered another problem which probably relates to base64 issues or json parsing.

const { atob } = require("@addons/Base64.js")
const { btoa } = require("@addons/Base64.js")

function onRequest(context, url, request){
  return request;
}
function onResponse(context, url, request, response) {
  var fromServer = response.body;
  writeToFile(fromServer, "~/desktop/fromServer.json");
  console.log("===ending replace?");
  //replace all "%3D" with "="
  if (fromServer.endsWith("%3D%3D")) {
				fromServer = fromServer.substring(0,fromServer.length - 6) + "=="; 
      console.log("%3D%3D");
			} else if (fromServer.endsWith("%3D")) {
				fromServer = fromServer.substring(0,fromServer.length - 3) + "="; 
        console.log("%3D");
			}
  var decodedOLD = atob(fromServer);
  writeToFile(decodedOLD, "~/desktop/decodedOLD.json");
  var jsonBody = JSON.parse(decodedOLD);
  writeToFile(jsonBody, "~/desktop/jsonBody.json");
  var oriseed = jsonBody["cache"]["replaced"]["battle"][0]["seed"];
  console.log("===original seed");
  console.log(oriseed);
  var decodedNEW = JSON.stringify(jsonBody);
  writeToFile(decodedNEW, "~/desktop/decodedNEW.json");
  response.body = btoa(decodedNEW);
  writeToFile(response.body, "~/desktop/responsebody.json");
  return response;
}

This script base64-decodes response from server into decodedOLD, then parse decodedOLD into better json format jsonBody, get/modify the seed in jsonBody, then return jsonBody back to decodedNEW, then base64-encodes decodedNEW back to response.body. However, even if I don't do any modification to the seed, decodedOLD is still different from decodedNEW, and the final response.body is far different from the original fromServer. I cannot locate the problem here, maybe another base64 issue or json parsing issue, my only guesses, cannot confirm.

decompress in desktop.zip

<!-- gh-comment-id:957217633 --> @phoenix5980 commented on GitHub (Nov 2, 2021): I have to reopen the issue since I encountered another problem which probably relates to base64 issues or json parsing. ``` const { atob } = require("@addons/Base64.js") const { btoa } = require("@addons/Base64.js") function onRequest(context, url, request){ return request; } function onResponse(context, url, request, response) { var fromServer = response.body; writeToFile(fromServer, "~/desktop/fromServer.json"); console.log("===ending replace?"); //replace all "%3D" with "=" if (fromServer.endsWith("%3D%3D")) { fromServer = fromServer.substring(0,fromServer.length - 6) + "=="; console.log("%3D%3D"); } else if (fromServer.endsWith("%3D")) { fromServer = fromServer.substring(0,fromServer.length - 3) + "="; console.log("%3D"); } var decodedOLD = atob(fromServer); writeToFile(decodedOLD, "~/desktop/decodedOLD.json"); var jsonBody = JSON.parse(decodedOLD); writeToFile(jsonBody, "~/desktop/jsonBody.json"); var oriseed = jsonBody["cache"]["replaced"]["battle"][0]["seed"]; console.log("===original seed"); console.log(oriseed); var decodedNEW = JSON.stringify(jsonBody); writeToFile(decodedNEW, "~/desktop/decodedNEW.json"); response.body = btoa(decodedNEW); writeToFile(response.body, "~/desktop/responsebody.json"); return response; } ``` This script base64-decodes response from server into `decodedOLD`, then parse `decodedOLD` into better json format `jsonBody`, get/modify the seed in `jsonBody`, then return `jsonBody` back to `decodedNEW`, then base64-encodes `decodedNEW` back to `response.body`. However, even if I don't do any modification to the seed, `decodedOLD` is still different from `decodedNEW`, and the final `response.body` is far different from the original `fromServer`. I cannot locate the problem here, maybe another base64 issue or json parsing issue, my only guesses, cannot confirm. [decompress in desktop.zip](https://github.com/ProxymanApp/Proxyman/files/7459035/decompress.in.desktop.zip)
Author
Owner

@NghiaTranUIT commented on GitHub (Nov 2, 2021):

@phoenix5980 can you try this Base64 Decode/Encode?

const { base64Encode } = require("@addons/Base64.js")
const { base64Decode } = require("@addons/Base64.js")

instead of atob, btoa because from what I know, there is a little difference in terms of implementation.

<!-- gh-comment-id:957223753 --> @NghiaTranUIT commented on GitHub (Nov 2, 2021): @phoenix5980 can you try this Base64 Decode/Encode? ```js const { base64Encode } = require("@addons/Base64.js") const { base64Decode } = require("@addons/Base64.js") ``` instead of `atob`, `btoa` because from what I know, there is a little difference in terms of implementation.
Author
Owner

@phoenix5980 commented on GitHub (Nov 2, 2021):

@phoenix5980 can you try this Base64 Decode/Encode?

const { base64Encode } = require("@addons/Base64.js")
const { base64Decode } = require("@addons/Base64.js")

instead of atob, btoa because from what I know, there is a little difference in terms of implementation.

The problem persists. I found that response.body wasn't encoded at all. Probably because the Base64 encoding process failed?

<!-- gh-comment-id:957233450 --> @phoenix5980 commented on GitHub (Nov 2, 2021): > @phoenix5980 can you try this Base64 Decode/Encode? > > ```js > const { base64Encode } = require("@addons/Base64.js") > const { base64Decode } = require("@addons/Base64.js") > ``` > > instead of `atob`, `btoa` because from what I know, there is a little difference in terms of implementation. The problem persists. I found that response.body wasn't encoded at all. Probably because the Base64 encoding process failed?
Author
Owner

@phoenix5980 commented on GitHub (Nov 3, 2021):

@NghiaTranUIT response.body is identical to decodedNEW, so response.body = btoa(decodedNEW); is not working. I tried base64Encode and the problem persists.

<!-- gh-comment-id:958586795 --> @phoenix5980 commented on GitHub (Nov 3, 2021): @NghiaTranUIT `response.body` is identical to `decodedNEW`, so `response.body = btoa(decodedNEW);` is not working. I tried base64Encode and the problem persists.
Author
Owner

@phoenix5980 commented on GitHub (Nov 21, 2021):

@NghiaTranUIT I tried several workarounds, no luck. Neither btoa() nor base64Encode() is working for decodedNEW. Not sure why.
output.zip

<!-- gh-comment-id:974819590 --> @phoenix5980 commented on GitHub (Nov 21, 2021): @NghiaTranUIT I tried several workarounds, no luck. Neither btoa() nor base64Encode() is working for decodedNEW. Not sure why. [output.zip](https://github.com/ProxymanApp/Proxyman/files/7576358/output.zip)
Author
Owner

@NghiaTranUIT commented on GitHub (Nov 24, 2021):

@phoenix5980 I run your sample code and turn of it has an error when fetching your seed (See the Console Log)

Screen_Shot_2021-11-24_at_14_24_34

Fix it

If I remove this code, the script run successfully.

Screen Shot 2021-11-24 at 14 24 23

Confirm that my request from Insomnia has base64 encoded string from response.body = btoa(decodedNEW);

Suggestion

@phoenix5980 can you remove the error code and test it again (Please open the console log)?

<!-- gh-comment-id:977603064 --> @NghiaTranUIT commented on GitHub (Nov 24, 2021): @phoenix5980 I run your sample code and turn of it has an error when fetching your seed (See the Console Log) <img width="1792" alt="Screen_Shot_2021-11-24_at_14_24_34" src="https://user-images.githubusercontent.com/5878421/143193380-a6f3535e-165f-4b5a-984d-f3efcd5350ad.png"> ### Fix it If I remove this code, the script run successfully. <img width="1792" alt="Screen Shot 2021-11-24 at 14 24 23" src="https://user-images.githubusercontent.com/5878421/143193440-17202ce0-fb93-49a1-bc3f-a9100d526cc1.png"> Confirm that my request from Insomnia has base64 encoded string from `response.body = btoa(decodedNEW);` ### Suggestion @phoenix5980 can you remove the error code and test it again (Please open the console log)?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Proxyman#950
No description provided.