[GH-ISSUE #1000] Feature: Will Proxyman support map local with some URL and different form data? #997

Open
opened 2026-03-03 19:23:37 +03:00 by kerem · 3 comments
Owner

Originally created by @fedorjia on GitHub (Sep 17, 2021).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1000

Originally assigned to: @NghiaTranUIT on GitHub.

All our interface requests are some URL: https://xxxx./data.json, and the methods are all Post.
Different requests are distinguished by the action field in the form data.
In this case, does Proxyman Map Local support ?

Originally created by @fedorjia on GitHub (Sep 17, 2021). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1000 Originally assigned to: @NghiaTranUIT on GitHub. All our interface requests are some URL: https://xxxx./data.json, and the methods are all Post. Different requests are distinguished by the action field in the form data. In this case, does Proxyman Map Local support ?
Author
Owner

@NghiaTranUIT commented on GitHub (Sep 17, 2021):

It's too complicated when defining a matching URL, with URL, Method, and the Body (Form data or JSON) on Map Local tool.

I highly suggest using the Scripting tool, because it's born to do it.

Here is the snippet code that achieve your expect:

function onResponse(context, url, request, response) {
  // console.log(response);

  // Get form body
  const formBody = request.body;

  // Condition
  if (formBody["userID"] === "123") {
      // Or map a local file as a body
      response.bodyFilePath = "~/Desktop/myfile.json"
  }

  // Done
  return response;
}
Screen Shot 2021-09-17 at 10 03 27
<!-- gh-comment-id:921418144 --> @NghiaTranUIT commented on GitHub (Sep 17, 2021): It's too complicated when defining a matching URL, with URL, Method, and the Body (Form data or JSON) on Map Local tool. I highly suggest using the Scripting tool, because it's born to do it. Here is the snippet code that achieve your expect: ```js function onResponse(context, url, request, response) { // console.log(response); // Get form body const formBody = request.body; // Condition if (formBody["userID"] === "123") { // Or map a local file as a body response.bodyFilePath = "~/Desktop/myfile.json" } // Done return response; } ``` <img width="1492" alt="Screen Shot 2021-09-17 at 10 03 27" src="https://user-images.githubusercontent.com/5878421/133717525-88dc7730-897f-495c-80b0-f80319e13389.png">
Author
Owner

@NghiaTranUIT commented on GitHub (Sep 17, 2021):

Here is the Snippet code you might find useful: https://docs.proxyman.io/scripting/snippet-code

<!-- gh-comment-id:921418314 --> @NghiaTranUIT commented on GitHub (Sep 17, 2021): Here is the Snippet code you might find useful: https://docs.proxyman.io/scripting/snippet-code
Author
Owner

@fedorjia commented on GitHub (Sep 17, 2021):

It's too complicated when defining a matching URL, with URL, Method, and the Body (Form data or JSON) on Map Local tool.

I highly suggest using the Scripting tool, because it's born to do it.

Here is the snippet code that achieve your expect:

function onResponse(context, url, request, response) {
  // console.log(response);

  // Get form body
  const formBody = request.body;

  // Condition
  if (formBody["userID"] === "123") {
      // Or map a local file as a body
      response.bodyFilePath = "~/Desktop/myfile.json"
  }

  // Done
  return response;
}
Screen Shot 2021-09-17 at 10 03 27

Nice, it works. Thank you.

<!-- gh-comment-id:921652748 --> @fedorjia commented on GitHub (Sep 17, 2021): > It's too complicated when defining a matching URL, with URL, Method, and the Body (Form data or JSON) on Map Local tool. > > I highly suggest using the Scripting tool, because it's born to do it. > > Here is the snippet code that achieve your expect: > > ```js > function onResponse(context, url, request, response) { > // console.log(response); > > // Get form body > const formBody = request.body; > > // Condition > if (formBody["userID"] === "123") { > // Or map a local file as a body > response.bodyFilePath = "~/Desktop/myfile.json" > } > > // Done > return response; > } > ``` > > <img alt="Screen Shot 2021-09-17 at 10 03 27" width="1492" src="https://user-images.githubusercontent.com/5878421/133717525-88dc7730-897f-495c-80b0-f80319e13389.png"> Nice, it works. Thank you.
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#997
No description provided.