cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to do a POST event in Synthetic Browser monitoring?

AntonioSousa
DynaMight Guru
DynaMight Guru

I'm trying to do a simple synthetic browser monitoring script, that does a POST request with some data. I have been struggling for more than an hour to find how to do such basic functionality, but seems it's better to seek some help here... Any clue?

Antonio Sousa
14 REPLIES 14

ChadTurner
DynaMight Legend
DynaMight Legend

@Antonio S. i was just able to create a synthetic monitor click path that goes to the Dynatrace Config API and creates a managment zone, and then deletes it. Where are you running into a snag?

-Chad

It must be because it's late Friday night here 😉


I have looked at the available browser clickpath events,


https://www.dynatrace.com/support/help/how-to-use-dynatrace/synthetic-monitoring/browser-monitors/br...


but there seems to be no way of making a POST, namely with the "navigate" event.


It does seem to be possible to do it with the HTTP monitors, but not
with the browser monitors, which was the one I referenced...

Antonio Sousa

@Chad T.,

Can you confirm please what type of synthetic monitor you used? Just to be sure it was not the browser clickpath?

Antonio Sousa

I did use the click path to do the post - I did not run into any issues with that - I dont think you can do it via the basic browser monitor as how would you input the Json payload.

-Chad

HannahM
Dynatrace Leader
Dynatrace Leader

How are you doing this? I've seen it work in Browser Clickpaths using fetch.

The first event has to be a Navigate in Clickpaths though, so you can only do this as a later event.

Synthetic SME and community advocate.

Not sure what "fetch" you are referring to?

Yes, the Navigate is the first. After that I have the following options:

Navigate seems the only option that could support a POST, but it is very limited in what we can do:

Antonio Sousa

Why are you adding it manually? its much easier if you add the chrome extension, then record your click path via the new browser window and access your www.<ApiEndPoint>.com and post the json payload.

-Chad

Yes, I normally use the Chrome extension, but in this specific case, it can't be done 😞

Now I understand how you did it 🙂

BTW, this is not a POST to an API. It is a specific POST in a login situation...

I'll probably have to go the Javascript route...

Antonio Sousa

ahh okay, id be interested if you can still be able to get it working via the click path set up - keep us in the loop how it goes.! you can always also create the Synthetic via in a Json then pass it into Dynatrace and have it create it.

-Chad

Apologies, I should have mentioned that it's a 'fetch' in JavaScript event that is required to do this.

Synthetic SME and community advocate.

HannahM
Dynatrace Leader
Dynatrace Leader

You'll want something like this:

api.startAsyncSyntheticEvent(); 
fetch('<yourRequest>', {
method: 'POST',
headers: {
'content-type': 'application/json'},
body: '<yourBody>'
}).then(response => response.text()).then(text => {
try {
api.info('Success');
api.finish();
} else {
api.fail("Invalid Response");
}
} catch (err) {
api.fail("Failed to Execute");
} });
Synthetic SME and community advocate.

Thanks Hannah,

I'm finally done, but didn't use the POST after all, because there were Javascript tricks, so I had to reverse engineer the HTML/Javascript code, and in the ending it was quite easier than I would have thought.

What seems could be a limitation around the few options available in Dynatrace, is easily worked around with Javascript 🙂

Antonio Sousa

Great Team Work!

-Chad

Hi Antonio,

Can you post the solution?

Featured Posts