Am unable to post json data to api using c# winform with parameter jsondata, the following steps i used to send data every time i tried same issue raising the code & errors are attached to this post.
URL & Datas as follows:
url: https:\\xxx.com\:jsondata
Step 1:
jsondata=
[{
"Name": "Raj",
"Mobile": "5546546556"
},
{
"Name": "Raj",
"Mobile": "5546546546"
}
]
Step 2:
jsondata=
{
"Name": "Raj",
"Mobile": "5546546526"
}
ERROR:
{"status":"FAILURE","Error":"A JSONObject text must begin with '{' at character 1 of &"}
Error Image:

Code in C#:
- public static async Task CallInvoiceAPI(string jsondata, string url)
- {
- try
- {
- HttpClient client = new HttpClient();
- var response = client.PostAsJsonAsync(url, jsondata).Result;
- var content = response.Content;
- var result = await content.ReadAsStringAsync();
- if (result.Contains("SUCCESS"))
- strStatus = "Success";
- else
- strStatus = "Failed";
- }
- catch (Exception ex)
- {
- strStatus = "Failed";
- }
- }

Suman RajRank #7,001 · 251 reputationPosted Mar 13, 2021, 1:04 AM EST
Same issue When i tried this method
Kiran MohantyRank #821 · 2.8K reputationPosted Mar 14, 2021, 4:38 AM EDT
Suman RajRank #7,001 · 251 reputationPosted Mar 14, 2021, 11:29 PM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Mar 13, 2021, 12:29 AM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts