0

Question about the API - Project Creation and Custom Fields

mark 1 year ago updated by Bartosz Budzyński 1 year ago 6

I have two questions that maybe someone here has experience with.

First, I'm trying to create projects via the API, and it seems that you need to have multiple calls to create a project.  Seems you need to...

  • Create the project
  • Update the source language
  • Update the target language
  • Update the notes
  • Update the due date
  • etc....

Rather than just a single call where you list all the fields to update. 

Is this correct? Am I doing something wrong? This seems like it's more work and more calls than necessary, but maybe it's just the way it is??

Second, I'm trying to update a custom field that contains date and time. However, it seems that the API only supports custom fields that are text fields - not date/time fields. Before I spend more time with trial and error, does anyone know if I'm correct or if we're just doing something wrong?

Thanks so much for your help! 

Hi Mark,

I'm guessing you're talking about Smart Projects, is that correct? In such case you need to provide just the minimum amount of information, here's how your request should look like:

{
    "name":"Project Name",
    "clientId": 5,
    "serviceId": 30
}

As of now, there's no way to update all the fields at once while creating Project. If that is something you would like to see in the future releases, please report your idea in Product Development Ideas forum. 

To update Date Time Custom Field you should send the following body with your request:

{
    "value": {
        "time": 1554736465000
    }
}

That long numeric value here is timestamp.

Hope that helps! 

Best,

Bartosz

thanks.

The first issue makes sense.

The second issue, we're trying to pass a date time variable to a date time custom field. We're formatting it as you say above, but we're just getting the date passed, no time.

Any thoughts on how I can troubleshoot this? It looks like I'm doing what you state above.

Thanks.

Hi Mark,

Please check the following:

- the field is date and time, not date only - to check that please do GET on /home-api/v2/projects/{projectId}/customFields

- date and time formatting is set correctly in General Configuration → Settings → Number and Date Formatting


Do you have this issue while setting date and time in custom field by hand? 

Best,

B.

We don't have this issue when setting by hand.

Here's what my date/time records look like when I pass them - 1552171576000

I can't figure out why it's not working

It looks like it now started working. :)

Great! :) Have a nice day then and let me know if you have any more questions.