[GH-ISSUE #1533] Map local - Matching rule. Add rules to response body #1528

Open
opened 2026-03-03 19:52:13 +03:00 by kerem · 2 comments
Owner

Originally created by @almaz010891 on GitHub (Feb 9, 2023).
Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1533

Description

Case:
All API calls for specific service have the same endpoint (e.g api/v2/tickets)
Sertain action specified in request body (e.g {"action":"book"}, {"action":"buy"})

I need create rule with response only for api/v2/tickets with "action":"buy", but this functionality doesn't exists for this case

Why this feature/change is important?

Map Local feature can't be use in some cases. For me it's very often case

Originally created by @almaz010891 on GitHub (Feb 9, 2023). Original GitHub issue: https://github.com/ProxymanApp/Proxyman/issues/1533 ## Description Case: All API calls for specific service have the same endpoint (e.g api/v2/tickets) Sertain action specified in request body (e.g {"action":"book"}, {"action":"buy"}) I need create rule with response only for **api/v2/tickets** with **"action":"buy"**, but this functionality doesn't exists for this case ## Why this feature/change is important? <!-- Explain why Proxyman needs this feature/change? --> Map Local feature can't be use in some cases. For me it's very often case
Author
Owner

@NghiaTranUIT commented on GitHub (Feb 9, 2023):

It's what the Scripting tools is designed for @almaz010891

Here is a tip:

  1. Make your request -> Right Click -> Tools -> Scripting -> It will automatically create a Scripting for your current Endpoint.
  2. Uncheck the Request, and check on the Response Checkbox, since we're mapping for the Response.
  3. use the following code. you can find all useful snippet code at https://docs.proxyman.io/scripting/snippet-code
function onResponse(context, url, request, response) {
  // console.log(response);

  // Check the request body condition
  if (request.body.action == "buy") {
    // Map body as a file -> As Map Local does
     response.bodyFilePath = "~/Desktop/myfile.json"
  }

  // Done
  return response;
}
<!-- gh-comment-id:1423893669 --> @NghiaTranUIT commented on GitHub (Feb 9, 2023): It's what the [Scripting](https://docs.proxyman.io/scripting/script) tools is designed for @almaz010891 Here is a tip: 1. Make your request -> Right Click -> Tools -> Scripting -> It will automatically create a Scripting for your current Endpoint. 2. Uncheck the Request, and check on the Response Checkbox, since we're mapping for the Response. 3. use the following code. you can find all useful snippet code at https://docs.proxyman.io/scripting/snippet-code ```js function onResponse(context, url, request, response) { // console.log(response); // Check the request body condition if (request.body.action == "buy") { // Map body as a file -> As Map Local does response.bodyFilePath = "~/Desktop/myfile.json" } // Done return response; } ```
Author
Owner

@almaz010891 commented on GitHub (Feb 9, 2023):

Thank you for this tip!

BUT...
I think it will be a good feature to do this via UI also. See my answear fot this issue - of course, scripting is good instrument, but in this case its may be too complicated for certain users. If you provide simplest way to use some features (e.g. this feature request) (I think UI is the simplest way) - you get the most handy/easy instrument for users)

<!-- gh-comment-id:1423921951 --> @almaz010891 commented on GitHub (Feb 9, 2023): Thank you for this tip! BUT... I think it will be a good feature to do this via UI also. See my answear fot this **[issue](https://github.com/ProxymanApp/Proxyman/issues/1532)** - of course, scripting is good instrument, but in this case its may be too complicated for certain users. If you provide simplest way to use some features (e.g. this feature request) (I think UI is the simplest way) - you get the most handy/easy instrument for users)
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#1528
No description provided.