1

I need to get data from a web service described as:

curl --header 'Authorization: Bearer fxTWi96Uxe97gsstB3kh99VNKRuuaW3s_1615442626' -X GET 'https://api.muztorg.ru/xvendor'

When calling a function:

HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer SR-OM5Bvb8Fh61S4jaRUktaOs8D5rv5C_1618658296");
client.DefaultRequestHeaders.Add("ContentType", @"application/json-rpc;charset=utf-8");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", @"SR-OM5Bvb8Fh61S4jaRUktaOs8D5rv5C_1618658296");

HttpResponseMessage response = await client.GetAsync(@"https://api.muztorg.ru/xvendor");
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();

I get a 502 error.
When I make a call from Fiddler, I get the same error.
enter image description here

But a call from Insomnia is successful. enter image description here

  • 1
    I'd use Fiddler to capture a successful call (made from Insomnia) and a call that fails and compare the requests to see what is different. – Francis Gagnon Apr 28 '20 at 12:06
  • What is the text of the error message? Also, edit those into your question. They aren't as helpful as comments. – Code Stranger Apr 28 '20 at 12:32
  • Added screenshots of calls to Fiddler and Insomnia – Nikolay Grigoryev Apr 28 '20 at 12:48
  • I meant that you should turn on Fiddler capturing, call the web service from Insomnia and then call the service from your C# code. You can then stop Fiddler capturing and examine the raw HTTP request made from Insomnia and compare it to the raw HTTP request made by your C# code. There should be a difference between the two that explains the error. – Francis Gagnon Apr 28 '20 at 12:51
  • I don't see Insomnia calls in Fiddler – Nikolay Grigoryev Apr 28 '20 at 13:06
  • You might be able to see the raw request in Insomnia somewhere. But it looks like you can make Insomnia use the Fiddler proxy manually (https://stackoverflow.com/a/59508874/870144). After that your Insomnia traffic should appear in Fiddler. – Francis Gagnon Apr 28 '20 at 13:25
  • Thank you. I don’t know what I did, but I changed the settings of the htps Fiddler and it worked. – Nikolay Grigoryev Apr 28 '20 at 14:48

0 Answers0