# Unable to populate Date picker value using the API "Error Bad request"

**URL:** <https://community.hubspot.com/t/unable-to-populate-date-picker-value-using-the-api-error-bad-request/16993>\
**Category:** APIs & Integrations\
**Tags:** companies\
**Created:** [October 31, 2019, 1:45pm UTC](https://community.hubspot.com/t/unable-to-populate-date-picker-value-using-the-api-error-bad-request/16993 "2019-10-31T13:45:13Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnjohn123123](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/johnjohn123123/32/31184_2.png) [@johnjohn123123](https://community.hubspot.com/u/johnjohn123123)\
**Post date:** [October 31, 2019, 1:45pm UTC](https://community.hubspot.com/t/unable-to-populate-date-picker-value-using-the-api-error-bad-request/16993/1 "2019-10-31T13:45:13Z")

</div>

We have created a property for our compnay named “TPS Update Date” of type DatePicker as follow:-

 ![TPS.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/f/b/fbe8a1fdccd867f99c3ed7aa6c138da8d9036240.png)

but when i try to populate this property using the API i will get this error:-

**The remote server returned an error: (400) Bad Request**

here is a sample of the passed JSON which will raise the error:-

`"[{\"objectId\":****,\"properties\":[{\"name\":\"email_gateway\",\"value\":\"******\"},{\"name\":\"website_gateway\",\"value\":\" ****.\"},{\"name\":\"mse_scan\",\"value\":\"No\"},{\"name\":\"mse_status\",\"value\":\"****.\"},{\"name\":\"tps_update_date\",\"value\":\"1572525038454\"},{\"name\":\"tps\",\"value\":\"Allowed\"}]}]"`

while if i remove the

`{\"name\":\"tps_update_date\",\"value\":\"1572525038454\"}`

property from the JSON i will be able to update the record. and i am converting the date inside our c# application to unix based ..so the value i am passing will be **1572525038454** (as shown in the above json)..

so i am not sure why this is not working for me?

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [November 4, 2019, 9:34pm UTC](https://community.hubspot.com/t/unable-to-populate-date-picker-value-using-the-api-error-bad-request/16993/2 "2019-11-04T21:34:02Z")

</div>

Hi, @johnjohn123123.

Apologies for the delayed response.

I do not see a company property with the internal name `tps_update_date` in your account with the Hub ID ending in **0966**. Am I looking in the correct account or did you delete the property?

Also, could you share a request URL you were testing with? (For example: `https://api.hubapi.com/companies/v2/companies/1234567`.) Please remove any `hapikey` values.

---

<div class="post-metadata">

**Author:** ![johnjohn123123](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/johnjohn123123/32/31184_2.png) [@johnjohn123123](https://community.hubspot.com/u/johnjohn123123)\
**Post date:** [November 5, 2019, 10:46am UTC](https://community.hubspot.com/t/unable-to-populate-date-picker-value-using-the-api-error-bad-request/16993/3 "2019-11-05T10:46:08Z")

</div>

Thanks for the reply. i am developing an console application for 3rd party compnay.. so do you need their ID? and can i send it in a confidentail way?

here is the c# code to intigrate with the API:-

```auto
using (WebClient wc = new WebClient())
 {
 string url = "https://api.hubapi.com/companies/v1/batch-async/update?hapikey= ******";
 Uri uri = new Uri(url);
 wc.Encoding = System.Text.Encoding.UTF8;
 wc.Headers.Add(HttpRequestHeader.ContentType, "application/json");
 var apiupdateresults = wc.UploadString(uri, data);
 Console.WriteLine("Api update results= " + apiupdateresults);
 }

```

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [November 5, 2019, 12:56pm UTC](https://community.hubspot.com/t/unable-to-populate-date-picker-value-using-the-api-error-bad-request/16993/4 "2019-11-05T12:56:01Z")

</div>

Sure, could you direct message it to me? Also, do you have an object ID you’ve been testing with that I could also use?

---

<div class="post-metadata">

**Author:** ![johnjohn123123](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/johnjohn123123/32/31184_2.png) [@johnjohn123123](https://community.hubspot.com/u/johnjohn123123)\
**Post date:** [November 5, 2019, 1:47pm UTC](https://community.hubspot.com/t/unable-to-populate-date-picker-value-using-the-api-error-bad-request/16993/5 "2019-11-05T13:47:28Z")

</div>

Hi @IsaacTakushi

I just send you a message with all the info you asked for.

Thanks for your help

---

<div class="post-metadata">

**Author:** ![johnjohn123123](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/johnjohn123123/32/31184_2.png) [@johnjohn123123](https://community.hubspot.com/u/johnjohn123123)\
**Post date:** [November 6, 2019, 10:45am UTC](https://community.hubspot.com/t/unable-to-populate-date-picker-value-using-the-api-error-bad-request/16993/6 "2019-11-06T10:45:28Z")

</div>

Hi @IsaacTakushi , did you have the chance to check the above ?

Thanks

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [November 6, 2019, 8:08pm UTC](https://community.hubspot.com/t/unable-to-populate-date-picker-value-using-the-api-error-bad-request/16993/7 "2019-11-06T20:08:30Z")

</div>

Apologies for the delayed response, @johnjohn123123.

Thank you for sending that information along!

It looks like the `tps_update_date` property in that account has the `type: "date"` instead of `datetime`.

As mentioned in [this article](https://developers.hubspot.com/docs/faq/how-should-timestamps-be-formatted-for-hubspots-apis), properties with a `type` of `date` only accept UNIX millisecond timestamps at **midnight**  **UTC** : “If you try to set a value that is not midnight UTC, you will receive an error.”

In your first post, you shared the timestamp value `1572525038454`, which is not at UTC midnight. If you send `1572480000000` instead, the `date` field should accept it.

Alternatively, you can change the `tps_update_date` property to be the `type: "datetime"` with [this endpoint](https://developers.hubspot.com/docs/methods/companies/update_company_property_group). See the example below:

```auto
PUT

https://api.hubapi.com/properties/v1/companies/groups/named/tps_update_date?hapikey=key

{ type: "datetime"}

```

If `tps_update_date` property is `datetime`, then it will accept `1572525038454`.

---

<div class="post-metadata">

**Author:** ![johnjohn123123](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/johnjohn123123/32/31184_2.png) [@johnjohn123123](https://community.hubspot.com/u/johnjohn123123)\
**Post date:** [November 7, 2019, 2:04pm UTC](https://community.hubspot.com/t/unable-to-populate-date-picker-value-using-the-api-error-bad-request/16993/8 "2019-11-07T14:04:01Z")

</div>

Hi Isaac,

thanks for the helpful reply. i fix this by converting the Date instead of the DateTime inside my code, and now i am able to populate the date picker value through the API.

---

<div class="post-metadata">

**Author:** ![tkoseoglu](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tkoseoglu/32/204239_2.png) [@tkoseoglu](https://community.hubspot.com/u/tkoseoglu)\
**Post date:** [October 24, 2024, 1:17am UTC](https://community.hubspot.com/t/unable-to-populate-date-picker-value-using-the-api-error-bad-request/16993/9 "2024-10-24T01:17:51Z")

</div>

Thank you. Following your advice, I was able to POST to the HS API by converting my C# DateTime to a UNIX long. (17533348999)

But now, when reading that exact same property FROM the HS API (instead of POSTing to it) the data in the property is now “2024-10-01”. Needless to say, I am not able to parse it into my original custom data type with has a property of type long?. How are we supposed to handle that?
