'Error code 400 on http request PUT request
I am trying this code but I am get Status Code 400, Bad request. I am trying to PUT data using json in a text file.
When I try this using postman it works fine when I put the below json in Body and set Type to PUT.
Json in File:
{
"objectPath": "/TestData1/TestData2/_C++TestData3/TestData6.TestData8:TestData15",
"functionName": "Test_FuncCall",
"generateTransaction": true
}
Console app .NET 4.7.2
static void Main(string[] args)
{
using (var client = new HttpClient())
{
JObject data = JObject.Parse(File.ReadAllText(@"D:\data.txt"));
client.BaseAddress = new Uri("http://127.0.0.1:5555/");
var content = new StringContent(data.ToString(), Encoding.UTF8, "application/json");
var response = client.PutAsync("test1/test2/test3", content).Result;
if (response.IsSuccessStatusCode)
{
Console.Write("Success");
}
else
Console.Write("Error");
}
Console.ReadKey();
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
