Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help to get payload from POST request #39

Open
thanggggg1 opened this issue Jul 24, 2024 · 5 comments
Open

Need help to get payload from POST request #39

thanggggg1 opened this issue Jul 24, 2024 · 5 comments

Comments

@thanggggg1
Copy link

I dont know how to get payload from POST request before update it

@sudharsan-selvaraj
Copy link
Member

@thanggggg1 Could you please explain the specific use case you're aiming to achieve so that we can provide more precise guidance?

@thanggggg1
Copy link
Author

thanggggg1 commented Jul 24, 2024

@sudharsan-selvaraj i used addMock to block the request like this

const blockRequest = async (urlPattern) => {
const mockId = await driver.execute('interceptor: addMock', {
config: {
url: urlPattern,
statusCode: 403, // Block by returning 403 Forbidden
responseBody: JSON.stringify({
message: 'Request blocked by interceptor',
}),
},
});
return mockId;
};

but i want to get the original requestBody before block, can you show me how. Thank you so much

@sudharsan-selvaraj
Copy link
Member

sudharsan-selvaraj commented Jul 24, 2024

@thanggggg1 You can try below methods to get the API details

  await driver.execute("interceptor: startListening");
  await blockRequest();
  // perform some action
  // ...
  const apiRequests = await driver.execute("interceptor: stopListening");
  console.log(apiRequests) // This will have all the API calls made from the app with the actual response

@thanggggg1
Copy link
Author

Thank you @sudharsan-selvaraj , i will try

@thanggggg1
Copy link
Author

thanggggg1 commented Jul 25, 2024

@sudharsan-selvaraj , i can not excecute when set up proxy

const capabilities = {
    platformName: 'Android',
    'appium:automationName': 'UiAutomator2',
    'appium:deviceName': 'emulator-5554',
    'appium:browserName': 'Chrome',
    'appium:intercept': true,
    'goog:chromeOptions': {
        args: [
            `--proxy-server=${proxy_host}`,  // Your public proxy
            '--ignore-certificate-errors'
        ]
    }
};

Do you know how to fix this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants