# StatusCode: 400 and Bad Request with C# when call createOrUpdate Contact

**URL:** <https://community.hubspot.com/t/statuscode-400-and-bad-request-with-c-when-call-createorupdate-contact/12001>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [July 21, 2016, 11:38am UTC](https://community.hubspot.com/t/statuscode-400-and-bad-request-with-c-when-call-createorupdate-contact/12001 "2016-07-21T11:38:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [July 21, 2016, 11:38am UTC](https://community.hubspot.com/t/statuscode-400-and-bad-request-with-c-when-call-createorupdate-contact/12001/1 "2016-07-21T11:38:55Z")

</div>

Hey guys, I’m trying to use the contact sync with C# but I’m receiving that error. I’m not sure if can be something with my json or with the header.

**Error:**  
{StatusCode: 400, ReasonPhrase: ‘Bad Request’, Version: 1.1, Content: System.Net.Http.StreamContent, Headers:  
{  
Access-Control-Allow-Credentials: false  
Vary: Accept-Encoding  
Vary: Accept-Encoding  
Connection: close  
Date: Thu, 21 Jul 2016 11:28:09 GMT  
Content-Length: 174  
Content-Type: application/json; charset=UTF-8  
}}

**This is my Json**  
{“Properties”:[{“Property”:“firstname”,“Value”:“tiago api”},{“Property”:“lastname”,“Value”:“maximo api”}]}

**My code:**

```auto
 using (HttpClient httpClient = new HttpClient())
 {
 httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");

 SyncContactObject p = new SyncContactObject();
 p.Properties.Add(new PropertyObject("firstname", "tiago api"));

 string postBody = JsonConvert.SerializeObject(p);

 var response = httpClient.PostAsync(uri, new StringContent(postBody, Encoding.UTF8, "application/json")).Result;

 return JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
 }

```

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [July 21, 2016, 12:22pm UTC](https://community.hubspot.com/t/statuscode-400-and-bad-request-with-c-when-call-createorupdate-contact/12001/2 "2016-07-21T12:22:52Z")

</div>

Hey [@Tiago\_Maximo](https://community.hubspot.com/u/tiago_maximo),

I think it’s the capitalization in your JSON, try lower casing all the parameters.

In my own tests this payload was successful:

```auto
{"properties":[
 {"property":"firstname","value":"tiago api"},
 {"property":"lastname","value":"maximo api"}]
}

```

but if I capitalized any of the params I got this 400 error:

```auto
{
 status:"error",
 message:"Json node is missing child property",
 correlationId:"c082e9d2-5a03-479a-8af1-d3da4191c386",
 requestId:"f5cc1c40-711f-4a5f-b299-6206eb22d4ef"
}

```

Also, it might help to print the full error message, looks like you’re just getting a generic `Bad Request` response related to the 400.

Sebastian

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [July 21, 2016, 10:30pm UTC](https://community.hubspot.com/t/statuscode-400-and-bad-request-with-c-when-call-createorupdate-contact/12001/3 "2016-07-21T22:30:59Z")

</div>

Thank you so much, that’s was my problem.

Just removed the capitalization and worked!!!

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [September 14, 2018, 8:14am UTC](https://community.hubspot.com/t/statuscode-400-and-bad-request-with-c-when-call-createorupdate-contact/12001/4 "2018-09-14T08:14:47Z")

</div>

Hi,

I am also getting same problem even i made everything lowercase. below is my request. kindly help me out.

string DATA = “{}”+ Environment.NewLine + " {“file”:“IMproductSearch”,“params”:{“pageStart”: 0,“pageSize”: 50,“listOfProducts”:[“PB0047”]}}";

SerializedRequest = JsonConvert.SerializeObject(DATA);

```auto
 string URL = "https://api-beta.ingrammicro.com:443/ea-api/v1/productsearchus";

 System.Net.Http.HttpClient client = new System.Net.Http.HttpClient();
 client.BaseAddress = new System.Uri(URL);
 byte[] cred = UTF8Encoding.UTF8.GetBytes("username:password");
 client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(cred));
 client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

 System.Net.Http.HttpContent content = new StringContent(JsonConvert.SerializeObject(DATA.ToLower()), UTF8Encoding.UTF8, "application/json");
 HttpResponseMessage messge = client.PostAsync(URL, content).Result;
 string description = string.Empty;
 if (messge.IsSuccessStatusCode)
 {
 string result = messge.Content.ReadAsStringAsync().Result;
 description = result;
 }

```
