how create new POST request with C#?

0 Answers 282 Views
Fiddler Classic
Max
Top achievements
Rank 1
Iron
Max asked on 06 Nov 2021, 06:02 PM

Hello, please tell me how to create a separate POST request using the C# language.
Initially, I tried to change the outgoing POST request from another application and resend it, but I get an error - "HTTP/1.1 504 Fiddler - Receive Failure".
And now you need to write a new request, specifying the headers and receiving a response.
And the whole question is how to do it all in C#?

I tried to use this code

 


    public static void OnBeforeResponse(Session oSession)
        {
           
        
            if (oSession.HTTPMethodIs("POST") ) 
            { 
    
    
                  String strBody =  oSession.GetRequestBodyAsString(); 
     
                  oSession.host="api.123.com";
      
                    string resultRequest = "request";
   
    
                    byte[] resulByte =   System.Text.Encoding.ASCII.GetBytes(resultRequest);
    
                
                    FiddlerApplication.oProxy.SendRequest (oSession.RequestHeaders, resulByte, null);            
    
               }

Nick Iliev
Telerik team
commented on 09 Nov 2021, 04:13 PM

The error 504 indicates that the request was received from the server but then was dropped for some reason, and no information was sent back. The reason might vary - it could be that the server expects a specific header or information or that the IP is not allowed (or other security techniques). There might also be a temporary issue with the server (server down or problematic connection).

Refer to this forum thread for other possible reasons and troubleshoot ideas related to this kind of error message.

No answers yet. Maybe you can help?

Tags
Fiddler Classic
Asked by
Max
Top achievements
Rank 1
Iron
Share this question
or