i'm new to C# and trying to use RestSharp to make an API request to Pay360
I have the request working in PostMan perfectly however when i add that to my project nothing appears in the console.
I have even tried here https://dotnetfiddle.net/obAJSf
can anyone point me in the right direction as to why i cant see the json response in the console
Related
When I am sending GET requests using chrome browser with the Talend API Tester I am getting HTTP Status Code 301 (Moved Permanently) and am redirected to the .pdf document. This is expected and desired behavior.
Now, I am implementing this in C# .NET Core 6 using the RestSharp. When I send the exact same request to the exact same endpoint I am receiving 200 OK and the JSON object.
If I add client.FollowRedirects = false;, then the status code of the response is 301, however, I am getting a link to a JSON file instead of .pdf.
Is any way to configure the RestClient client of RestSharp so that be able to receive the link of the .pdf as it does with the Talend API Tester?
I spend the day on this... Any help or suggestions would be huge.
Hello everyone,
I'm doing a request in SoapUI like in the photo below and I'm trying to make the same request in a SQL Server Database Project in Visual Studio...
I kind of copied the functions needed for creating the webRequest from here Client to send SOAP request and receive response but I'm kind of stuck now because of the action.
What do I need to write for the action? In my case there is a php, I'm a bit confused.
I've tried couple of things but the response remains the same.. ( -1 )
The SoapUI request
There is this WS-A panel with some info as well about the request
Also, here is my envolope for the request... just in case
I've tried adding the web reference in another project and this is what I got ( I'm not allowed to use a web reference to this unfortunately.. )
I appreciate your time spent, thank you!
I have a Postman call that successfully returns readable response, such as:
Now, I want to execute the same call via C# and .Net Core RestClient. Postman has an option to generate a code snippet for different languages, here is an example for C#:
But when executing it, within my C# app, I receive an error with response, instead of the same Postman response with valid result:
How come?
Unless I'm grossly misunderstanding, you're getting xml when you want json and the headers visible in screenshots are the only headers on the request?
It sure looks like you want to specify the Accept header.
Accept:application/json
Further Reading
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept
I am trying to submit some data to an API using RestSharp in C# and it seems all of my parameters are added to the Headers collection - or that is just how they are catalogued in VS.
Here is my code
var client = new RestClient("https://api.com");
var request = new RestRequest("/recognize", Method.POST);
request.AddHeader("app_id", "");
request.AddHeader("app_key", "");
request.AddHeader("Content-Type", "multipart/form-data");
request.AddParameter("gallery_name", model.gallery_name);
request.AddParameter("image", model.image);
var response = client.Execute(request);
The error back from the API says the request is missing the gallery_name and image parameters, but looking into the request object they are there in the Headers collection.
I can make the call in Postman where the method is set to Post and the Body is set to form-data, along with 2 key/value pairs listed.
What am I doing wrong?
In your question you says "I can make the call in Postman ...".
Normally if the Postman request is successful then should the generated RestSharp code from Postman works, if there are no open issues in the RestSharp library that can cause your problem.
It's hard to debug and reproduce the problem from here, but I can give the following that you can check.
Check this:
If your Postman request works and is successful then check the Restsharp code generated by Postman:
Click on "code"
Choose in the combobox for "C# (RestSharp)"
Try the RestSharp code that you see in the window, if the code doesn't work check this URL for known issues.
On a sidenote: If you see a known issue that can cause your error, try to test with a previous version of RestSharp or an alpha version.
I hope you can now further investigate and debug the problem.
(I had similar problems and resolved it successful with this way of investigating and debugging)
Very new to this. I am using a wsdl. Generating the web reference and .net builds the classes in references.cs. Now is there any way I can get the soap request going out though any c# methods in my code?
Getting at System.Xml.Serialization.XmlSerializer.Serialize error in prod but absolutely working fine in UAT. No body has no clue on why? Can someone pls provide insights on getting the soap request going out ?
You can use tool fiddler to track the request and responce