logo
down
shadow

What should TResult be when using public async Task to return json response from API HTTP Post


What should TResult be when using public async Task to return json response from API HTTP Post

By : user2173867
Date : October 19 2020, 08:10 PM
seems to work fine You're getting that error because ReceiveJson returns a dynamic, not a string. This allows you to work with the result as an object with properties without having to declare a matching class. This is handy for quick & dirty JSON responses where you know the shape of the response won't change, but you give up compile-time type checking, so in most cases I recommend creating a matching class and using RecieveJson.
If you really want to get a string back, you can use ReceiveString instead. If you're just forwarding the response off to something else or dumping it to a log or something that can be useful. But if you need to somehow process the JSON result I'd recommend using ReceiveJson or ReceiveJson so you can work with the result as a C# object.
code :


Share : facebook icon twitter icon
return Task.ContinueWith<TResult>() without knowing TResult

return Task.ContinueWith<TResult>() without knowing TResult


By : Julian Freeman
Date : March 29 2020, 07:55 AM
Hope this helps Sounds like a case for dynamic. I'll try to use as little dynamic as possible. First we define a strongly-typed helper:
code :
static Task<TResult> SetContinuation<TResult>(Task<TResult> task)
{
    return task.ContinueWith(
        t =>
            {
             if(someCondition)
             {
                 throw new Exception("Error");
             }

             return t.Result;
        });
}
Task continuation = SetContinuation((dynamic)unknownReturnType);
Why is it not necessary to return a Task when the signature is public async Task MethodName?

Why is it not necessary to return a Task when the signature is public async Task MethodName?


By : spiritualspells
Date : March 29 2020, 07:55 AM
I hope this helps you .
Why does this compile and work without a return statement for the Task?
why the async Task<TResult> always return empty value

why the async Task<TResult> always return empty value


By : Ruud Borst
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Your problem seems to be that waiting for test().Result causes a dead lock. The reason is that this line
code :
await Task.Delay(1000);
await Task.Delay(1000).ConfigureAwait(false);
async Task<TResult> - Return Value

async Task<TResult> - Return Value


By : Marcelo Almeida
Date : March 29 2020, 07:55 AM
Hope this helps Your signature is correct, and return Task
The deal is when you call a, you have two ways to get string :
code :
public string get()    // For option 2 say public async Task<string> get() 
{
    //Option 1 - Using Task<string>
    Task<string> cnt = module.a<string>(x, file()); // or var cnt = ...
    MessageBox.Show(cnt.GetAwaiter().GetResult()); // Return the string you want

    //Option 2 - Using await
    MessageBox.Show(await module.a<string>(x, file())); // Return the string you want
}
HTTP POST does not return expected JSON response

HTTP POST does not return expected JSON response


By : khuram Imtiaz
Date : March 29 2020, 07:55 AM
it fixes the issue Turns out the code was perfectly alright and the issue was on the rim.public property file where the application.handler.http.AuthenticationSupport was set to true and because of this it was not loggging in.
Now I set it to false and get the correct response.
Related Posts Related Posts :
  • Headless Firefox in Selenium C#
  • How do I start a .exe with a json string as parameter correctly?
  • StreamContent not loaded to the end
  • HAP parses formatting in HTML documents
  • repeat and count a loop in an unordered sequence in C#
  • Redundant Casting in Visual studio
  • Lost references in Visual Studio 2017 solution
  • Is there a way to add two numbers using a private constructor in C#
  • Is it possible to execute multiple SSH commands from a single login session with SSH.NET?
  • How can I get NHibernate to map to a Tuple or Class?
  • MVC 5 C# Window Authentication pop up when I navigate to a certain area
  • Mongo C# driver toJson() DateTime
  • Coprime integers
  • What is the purpose with files ending with *CS.cs in Xamarin Forms projects?
  • MVC5 / Entity | Update/Create Complex Model
  • How to return auto increment ID from SQL using Petapoco ORM in .NET MVC
  • Create new web app offline c# using Visual Studio
  • How many times is ordered the IEnumerable in this case?
  • C# error when update database 2008 to sql 2016
  • How to insert string in multiple continuous pattern in windows c#
  • How to send temp data from Partial View to its parent View
  • C# encapsulation when getting updates from asynchronous method
  • Asp net core Content Security Policy implementation
  • @Html.DropDownList() Placeholder as Disable and Selected
  • Set AM/PM in Material Time Picker WPF
  • Ninject passing reference in constructor
  • C# Entity Framework text SQL query wrapper
  • Core 2.0 MVC - AD Group Authorization for logging
  • Decentralized NLog Target per Http request
  • How to use x:Object and when?
  • Displays file icons in asp.net on GridView
  • How do I avoid two (or more) threads that work on a table at the same time to not work on same row?
  • Add xml attribute for property in DB First
  • How do i execute 2 sql queries by clicking a button [C#]
  • convert jsonstring to objects c#
  • How do request a correct access token in ASP.NET Core for Azure AD to access Microsoft Graph
  • How to run a .NET Core console application on Linux
  • UI not updating for bound element
  • C# Odata v4 open type raw values
  • DocumentFormat.OpenXml Modify Creator Propery of Document
  • How to SetBasePath in ConfigurationBuilder in Core 2.0
  • ASP MVC5 public readonly variable changes value when it should not
  • How to conditionally select item from hashset with queryable linq?
  • Progress Bar C# not showing the real progress
  • Correct logic to reconnect in SignalR with HubConnection
  • ComboBox with two or more sections
  • .NET listbox to SQLite DB
  • C# Ninject binding from Dictionary<Type, Type>
  • asp.net mvc -view displaying real-time progress status
  • Getting reference to dependent in service with generic type
  • Implementing EqualityCompare vs overriding GetHashCode and Equals
  • C# Linq Find all indexes of item in List<int> within another List<int>
  • XML image how to display at data grid columns in c#.net
  • How to override Equals and GetHash of HashSet
  • Creating Windows authentication and SQL Server authentication in login form
  • How to interop with Azure Service Bus topics created by MassTransit using Rebus?
  • MVC 5 Google Calendar Integration
  • C# - Use parallel arrays to calculate cost of a phone call in GUI
  • Use a int in entire code
  • How to display newly added element at the top of StackPanel in WPF?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org