HTTP utils and login to Microsoft API

Using this URL :
How can I see what I have in the Body ? My DTO.Request.AuthRequest() contain my secret and id etc…

I can’t see my content pass from my DTO…

        Console.WriteLine("Loading Azure Consumption for period: " + Period);
        var req = new DTO.Request.AuthRequest();
            var url = req.ToPostUrl(); // This construct my url correctly cause I have my Route with my tenant in my DTO
            var response = url.PostJsonToUrl(req, r =>
            }, rep =>
        catch (Exception e)

I don’t understand the question, the req is your Request DTO which is what’s used for the HTTP Request Body, from this example it looks like you’re sending an empty AuthRequest DTO.

You can’t access the Request Body that’s written to the Request Stream, but what gets sent is your DTO serialized as JSON, e.g. req.ToJson(). To view the actual HTTP Request that’s sent you’d need a HTTP Packet sniffer like Fiddler.

Thanks Mythz, I will check with Fiddler. The AuthRequest is fill. But did not put it in the forum. secretid etc…

Work well with 3 lines now.

The body cannot be a json so in my request I create a ToBody() function to have a correct format.

            var url = req.ToPostUrl();
            var response = url.PostStringToUrl(req.ToBody());
            var authresponse = response.FromJson<AuthResponse>();
    public string ToBody()
        return string.Format("{0}={1}&{2}={3}&{4}={5}&{6}={7}", nameof(grant_type), grant_type,
                                                                nameof(client_id), client_id,
                                                                nameof(client_secret), client_secret,
                                                                nameof(resource), resource);

Now let see how I can pass my token…

        var response = url.GetJsonFromUrl(requestFilter: req =>

Fiddler is magic by the way !!!