Send HTTP Request to Google Server Side - google-tag-manager

how can I send a request to Google Server Side Tag Manager Instance?
With data-tag templates from Stape.io and other tools it worked.
But I want to send out a HTTP Request from Postman or something and see it on the Debug Mode on Server Side.
I always get an 400 and see nothing in debug mode.
Maybe you can help :) Thanks
I sent a get request through Postman to my Server Side instance and expect to see the request in the debug preview mode.

For a request to show up in the SGTM Preview Mode, it needs to have the X-Gtm-Server-Preview HTTP header.
To find yours, open the Preview Mode, click the three dots in the top right hand corner and click "Send requests manually".

Related

What is http request "HTTP/0.0"?

I make some Angular calls to an API and sometimes I see the request is being requested with protocol 0.0 - "HTTP/0.0" (ideally this would be "HTTP/1.1") by client and in response we see nothing but "HTTP/0.0 0"
In our case it turned out that Chrome was recording a blank HTTP version in its network log for requests that failed. The 'response' had a blank HTTP version too. Fiddler shows blank HTTP versions as HTTP/0.0.
You don't say where you saw your HTTP/0.0, but if it was in fiddler then even in the 'raw' view it's actually manipulating what you see.
You can double check this by downloading the .har file (right click in the network tab of the dev tools) and viewing the .har in a text editor rather than in Fiddler or some other viewer that might manipulate the results.

Can't view GET request to remote API in Chrome

I have set up a section on my Drupal 7 site to show press releases that are fetched from a remote service through a REST API. It works fine to fetch and show all press items via a very specific POST request.
But I have no luck when I want to fetch just one specific press item, which according to the API docs shall be done with a GET request.
In order to see what happens I want to view the GET request to the remote URL in Chrome, but I can't figure out how.
This is how I do it: when opening the page where I want to show only one full press item:
On my press item page...
https://examplesite.com/newsroom/pressrelease
... I have a custom block where this code is run:
$item_id = (int)$_GET['item_id'];
// Fetch specific pressRelease from remote API with custom token
$headers = array('Custom-Token'=>'[custom-token]', 'Accept'=>'text/json', 'Content-Type'=>'text/json');
$url = "https://[remote newsroom url/]$item_id";
dpm($url);
$options=array(
'method'=>'GET',
'headers'=>$headers
);
$result=drupal_http_request($url, $options);
dpm($result);
$data = json_decode($result->data, true);
dpm($data);
With my dpm statements I can see the request on the page, but I would really like to see the actual request and response in Chrome dev tools (under the Network tab). But there is nothing to be found. I have tried using extensions like Live HTTP Headers, with no luck. Only the request to view the local page is shown not the remote one.
How can I see the http request to the remote URL in Chrome or Firefox?
EDITED... the problem might be that the request is done while the page is generated on the server side, before it is loaded on my site?
The code that you are executing, lies on the server and cannot be viewed from network tools of the browser, The browser developer tools will be able to track only those request that are made directly from your browser, in the form of AJAX request etc.
In order to view the actual request, you need to use a network proxy like Charles or Fiddler on your server which will track all HTTP network traffic from your server.

Apigee response not getting sent to angular application

I have an angular that sends calls to Apigee. After tracing the calls i can see that a response is returned. However the client does not get the response. I have no idea what i could be missing in this instance.
I have set up CORS correctly on Apigee and can see the options preflight response getting called successfully. The issue really is on the second call, a response is returned but the client receives null data
Well, working with the description you've sent, what you could do:
Debug the API call using the Chrome Developer tools: use ctrl-shift-J and then choose the 'network' tab. See if the clal is coming in. Clicking on the specific API call shows you the response
also maybe check the console that is shown when using above command (crl-shift-J)
indeed check the Apigee trace. But if the trace shows a reply is sent, then probably it is.
add some console.log in the Angular application or try to debug it so that you are certain it's an Angular issue.
maybe share some code so that we can better help you.

When I make a request to a server can I see all the requests made by that server to another server?

I need to know which requests a webpage sends. Basically the site i call, calls another service/api/url whatever and receives the data (probably within javascript) and show me this. Can i see all the calls it make?
Edit: concrete example:
From this site (http://www.flickriver.com/lenses/nikon/) you can choose a lens, at that moment, the page sends a request to flickr, and get all the data. But in chrome developer tools i could not see this request.
Here is a screenshot of get requests. I have looked through them but could not see any request to flickr.
The first is request to the page. And the sixth one is the picture request already, where it requests the picture by its id. So in between other 4 requests should contain a request to the external source which gives the picture id in return or do i miss sth?
And what if the backend makes this request? Do i still need to see this request in developer tools?
No, of course you cannot see the calls made by some server to another server. Why would you expect to be able to do that? Those calls have nothing to do with the browser. The browser knows nothing about those requests. The browser knows only about requests that it itself initiated. Devtools can only report on requests made by the browser. If in fact there were some way to spy on the requests made by a server to another server, it would be gaping security hole.

What happens to an http Request when the user leaves page in the meantime?

I'd like to keep some information on the client which element was clicked and thus save the information within a cookie, but it's a third party cookie because I need this information on antoher page (affiliate-tracking is the context) so I'd have to set it via http request as far as I see it. Javascript would only allow me to place a within the same domain - which will be left after the click.
Now I can send of the http-request via Javascript with the onbeforeunload event, but what happens to this http-request once the browser has left the page? Does it still "take the call" and places the cookie or does it ignore the call since the website from which the request originated is no more?
Could not find any documentation on this, so I'd be grateful if anyone had a clue.
Thanks,
Benjamin
If you close your browser (or click on a different link/page) after you have sent a Http request, the response from that Http Request will disappear into a black hole. Indeed, the web server may or may not actually send the full response depending on the size of the requested page and the point at which the requesting socket was closed.

Resources