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";
- }
- }