Dear all,
in my attempt to update data in Espo via the API from a C# application I only get Bad Request as response. After hours of trying I started to implement a simple example based on the API documentation and that also doesn't work.
This is what I'm doing in my (C#) code:
This is the generated Request
Request: Method: POST, RequestUri: 'http://myespo.org/api/v1/Account', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
Accept: application/json
X-Api-Key: aab35cf80b4e9f4a2522855c2ff359e6
Content-Type: application/json; charset=utf-8
Content-Length: 48
}
The answer is a simple 400 - Bad Request without any further information. I checked the log and it shows the following:
[2020-xxxxxxx] Espo.ERROR: (400) POST /Account; line: 81, file: /var/www/html/application/Espo/Core/Controllers/Record.php [] []
Any ideas what is going wrong?
Best regards
Jan
PS: GET works fine and thus I would assume that authentication is not an issue.
in my attempt to update data in Espo via the API from a C# application I only get Bad Request as response. After hours of trying I started to implement a simple example based on the API documentation and that also doesn't work.
This is what I'm doing in my (C#) code:
Code:
HttpClient client = new HttpClient(); client.BaseAddress = new Uri(URL); // Add an Accept header for JSON format. client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("X-Api-Key", apiKey); var payload = "{\"name\":\"AnotherCustomer\", \"type\":\"Customer\"}"; var kundenUrl = "api/v1/Account"; var content = new StringContent(payload, Encoding.UTF8, "application/json"); HttpResponseMessage resposne = client.PostAsync(kundenUrl, content).Result;
Request: Method: POST, RequestUri: 'http://myespo.org/api/v1/Account', Version: 1.1, Content: System.Net.Http.StringContent, Headers:
{
Accept: application/json
X-Api-Key: aab35cf80b4e9f4a2522855c2ff359e6
Content-Type: application/json; charset=utf-8
Content-Length: 48
}
The answer is a simple 400 - Bad Request without any further information. I checked the log and it shows the following:
[2020-xxxxxxx] Espo.ERROR: (400) POST /Account; line: 81, file: /var/www/html/application/Espo/Core/Controllers/Record.php [] []
Any ideas what is going wrong?
Best regards
Jan
PS: GET works fine and thus I would assume that authentication is not an issue.
Comment