I am trying to insert an object in BullHorn using its API. Besides, I am using a PUT method as documentation indicated me.
My code is:
HttpResponseMessage response = new HttpResponseMessage();
HttpClientHandler clientHandler = new HttpClientHandler();
clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
HttpClient client = new HttpClient(clientHandler);
System.Net.ServicePointManager.Expect100Continue = false;
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
client.Timeout = TimeSpan.FromSeconds(5);
client.BaseAddress = new Uri(bhURL);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var model = JsonConvert.SerializeObject(body);
var model1 = new StringContent(model, Encoding.UTF8, "application/json");
response = await client.PutAsync(bhURL, model1).ConfigureAwait(false);
The response is always 400. But the strange part here is that I used the bhURL (token included as querystring) and the body on postman, and it was perfect.
I have checked:
var model = JsonConvert.SerializeObject(body);
var model1 = new StringContent(model, Encoding.UTF8, "application/json");
Is serializing correctly the body, and it is, but the PUT call still returns 400.
My postman´s headers configuration is really basic:
Any help please?