Search code examples
c#jsonpayloadflurl

how to write Request Payload using flurl


how to write Request Payload using Flurl, I only know the general form of writing.

example payload:

text1:xxx
text2:1

code on flurl :

PostJsonAsync(New
{
   text1= "xxx",
   text2 = 1
});

how to write json to flurl if the payload is like this

text1:[]
text2:"{"refer_urls":[]}"

Thank you for the help.


Solution

  • Use PostStringAsync instead of PostJsonAsync. This skips the JSON serialization step and allows you to specify the precise string you want to send, which is what you want here since the payload as a whole is not valid JSON.