# Is it possible to manipulate URLs in an VMAP response using the Network API?

**URL:** https://community.bitmovin.com/t/is-it-possible-to-manipulate-urls-in-an-vmap-response-using-the-network-api/1017
**Category:** Support
**Tags:** bitmovin-player, bitmovin, web
**Created:** [July 15, 2022, 9:46am UTC](https://community.bitmovin.com/t/is-it-possible-to-manipulate-urls-in-an-vmap-response-using-the-network-api/1017 "2022-07-15T09:46:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![callum.amor](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@callum.amor](https://community.bitmovin.com/u/callum.amor)
#### Post date: [July 15, 2022, 9:46am UTC](https://community.bitmovin.com/t/is-it-possible-to-manipulate-urls-in-an-vmap-response-using-the-network-api/1017/1 "2022-07-15T09:46:52Z")

</div>

Can I use one of the Network API requests to append or manipulate advert playback URLs from a VMAP response?

Is there any way to enable the preprocessHttpRequest for Ads network requests like in the below guide?

> **[Bitmovin Docs - Player | Network API - HTTP request/response manipulations...](https://bitmovin.com/docs/player/articles/network-api-http-request-response-manipulations-per-platform)**
>
> HTTP request/response manipulations supported by Bitmovin SDK

---

<div class="post-metadata">

### Author: ![Kishore](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/kishore/32/174_2.png) [@Kishore](https://community.bitmovin.com/u/Kishore)
#### Post date: [July 15, 2022, 10:32am UTC](https://community.bitmovin.com/t/is-it-possible-to-manipulate-urls-in-an-vmap-response-using-the-network-api/1017/2 "2022-07-15T10:32:56Z")

</div>

The player can only intercept the ad manifest (VMAP playlist) not the actual ad playback URL’s, so the option available is to Intercept the VMAP playlist response using `preprocessHttpResponse` callback and parse the XML to add the custom parameters.

```auto
network: {
                preprocessHttpResponse: function(type, response) {
                    if (type === bitmovin.player.HttpRequestType.MANIFEST_ADS) {
                        // parse response.body xml and add custom params
                    }
                }
            },

```

---

<div class="post-metadata">

### Author: ![Kishore](https://sea1.discourse-cdn.com/flex015/user_avatar/community.bitmovin.com/kishore/32/174_2.png) [@Kishore](https://community.bitmovin.com/u/Kishore)
#### Post date: [July 15, 2022, 10:35am UTC](https://community.bitmovin.com/t/is-it-possible-to-manipulate-urls-in-an-vmap-response-using-the-network-api/1017/3 "2022-07-15T10:35:38Z")

</div>

Sample code for parsing the VMAP [XML](https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpremidpostpod&cmsid=496&vid=short_onecue&correlator=) and adding custom params, you need to change the tags/ custom values based on the requirement

```auto
network: {
                preprocessHttpResponse: function(type, response) {
                    if (type === bitmovin.player.HttpRequestType.MANIFEST_ADS) {
                        let parser, vmapXml;
                        parser = new DOMParser();
                        vmapXml = parser.parseFromString(response.body, "text/xml");
                        let adaptationSetNode = vmapXml.getElementsByTagName("vmap:AdTagURI"); 
                        for (let i = 0; i < adaptationSetNode.length; i++) {
                            adaptationSetNode[i].firstChild.nodeValue += "&custom_token=value" 
                        }
                        response.body = (new XMLSerializer()).serializeToString(vmapXml);
                        return response;
                    }
                }
            }

```

---

<div class="post-metadata">

### Author: ![callum.amor](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@callum.amor](https://community.bitmovin.com/u/callum.amor)
#### Post date: [October 26, 2022, 3:25am UTC](https://community.bitmovin.com/t/is-it-possible-to-manipulate-urls-in-an-vmap-response-using-the-network-api/1017/4 "2022-10-26T03:25:13Z")

</div>

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.
