question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BrowserMob does not capture post Payload data( getPostData() returns null )

See original GitHub issue

Browsermob version (2.1.4) Embedded Mode

I have set the proxyServer.setHarCaptureTypes(CaptureType.REQUEST_HEADERS, CaptureType.REQUEST_CONTENT) ;

Still the getPostData on harRequest returns null.

My Sample code is pretty much same as example in docs but for my project URL. ` BrowserMobProxy proxy = new BrowserMobProxyServer(); proxy.start(0);

// get the Selenium proxy object
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);

// configure it as a desired capability
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);

// start the browser up
WebDriver driver = new FirefoxDriver(capabilities);

// enable more detailed HAR capture, if desired (see CaptureType for the complete list)
proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);

// create a new HAR with the label "yahoo.com"
proxy.newHar("MyProject");

// open yahoo.com
driver.get("My URL");

// get the HAR data

List <HarEntry> entries = proxy.getHar().getEntries().stream().filter(entry -> entry.getRequest().getMethod().equals(“POST”)).filter(entry -> entry.getRequest().getPostData().getText().contains(“abc”)).collect(Collectors.toList());`

.getPostData().getText() throws nullPointer exception.

Any Suggestions?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6

github_iconTop GitHub Comments

7reactions
cglacetcommented, Sep 4, 2018

Nevermind I found the answer, I was just passing the parameter to the proxy creation instead of the HAR creation.

For other python users:

har_options = {'captureContent': True}
proxy.new_har(url, options=har_options)
1reaction
jekhcommented, Jan 27, 2017

Use proxyServer.enableHarCaptureTypes(...) to turn a capture type on without affecting other capture types. To use an HTTP analogy, enable... is like a POST, set... is like a PUT. The documentation for those methods explains this pretty well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HarRequest.Postdata() returning NULL - JAVA + SELENIUM+ ...
For HTTP traffic , i am using browsermob proxy I am getting the ... getPostData() returns the actual post data ... I could...
Read more >
How to capture http POST requests with ... - Stack Overflow
Using the following logic I can only capture the key/value pairs of the POST header but not the actual POST data (aka the...
Read more >
net.lightbody.bmp.core.har.HarRequest java code examples
getDecodeValue()); if (harRequest.getPostData() != null) { if(harRequest. ... Does not populate fields within the request, * such as the error message.
Read more >
net.lightbody.bmp.filters.HarCaptureFilter Maven / Gradle / Ivy
The class is part of the package ➦ Group: net.lightbody.bmp ➦ Artifact: ... file at the time this request is received (can be...
Read more >
How to capture http POST requests with browsermob-proxy ...
Using the following logic I can only capture the key/value pairs of the POST header but not the actual POST data (aka the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found