0

I have a .net core 3.1 azure function apps that calls Azure API. I am passing a custom header "Request-Id", my custom header is a Guid converted to string. I don't know but for some reason, when my request reaches to the API Server the "Request-Id" header value changed. For example, I passed E2AD0ABE-9D8F-4D7E-BFAB-AA8A756DF9D2 in the "Request-Id" header but when it reached the API it become 3794FBB7-1564-4BD9-86B9-F136AF9D61DF|.898989834

I tried it in .net core2.0 client and it's working ok. I don't know if this is a bug in .net core 3.1 or I just need to do it(passing custom header) on a different way.

        var requestId  = Guid.NewGuid().ToString();

        using (var client = new HttpClient())
        {
            var uri = "https://testurl/v1/Pr/";
            var request = new HttpRequestMessage
            {
                Method = HttpMethod.Post,
                Content = sc,
                RequestUri = new Uri(uri)
            };
            client.DefaultRequestHeaders.Add("Request-Id", requestId);
           
             var result = client.SendAsync(request).Result;
            if (result.IsSuccessStatusCode)
            {
                response = result.StatusCode.ToString();
            }
        }
RAM
  • 91
  • 1
  • 10
  • Does this answer your question? [Custom header to Httpclient request](https://stackoverflow.com/questions/35907642/custom-header-to-httpclient-request) – Jawad Jul 06 '20 at 05:12
  • You mean `client` as request or `result` as response changed the header string? – Tấn Nguyên Jul 06 '20 at 05:14
  • What does fiddler say. – TheGeneral Jul 06 '20 at 05:15
  • What do you mean with I tried it in Net core 2? Do you mean the client is NET Core 2 or the server or both? Because if it’s just the client, that would be very weird. – Legacy Code Jul 06 '20 at 05:36
  • You mean "Request-Id" sent in HTTP request gets changed to some other GUID/random string when it reaches to server? – Nilesh Shinde Jul 06 '20 at 05:46
  • I mean .net core 2.0 client. Yes "Request-Id" is sent in Http request get changes to some other Guid/random when it reaches to server – RAM Jul 06 '20 at 07:07
  • @Jawad, Thanks for suggestion but it doesn't resolve the issue. – RAM Jul 06 '20 at 07:09
  • did you check the Azure API Mgmt Transformation policies? you can also try to rename your custom header entry. – Falco Alexander Jul 06 '20 at 07:18

0 Answers0