Post

2 followers Follow
0
Avatar

REST API error - Cannot convert value to type 'ObjectIdentifier' when creating Parent link

Hi,

I'm starting to use the REST API but when I create a Parent link I get an error. This is a sample payload I'm sending to create a task and the corresponding link to an existing task in Clarizen (using the Bulk service):

 

{

  "requests": [

    {

      "url": "/data/objects/Task",

      "method": "PUT",

      "body": {

        "id": "/Task/ae35cd4b-ed6b-48b5-9ff5-de3da68cf635",

        "Description": "Test Description",

        "Name": "Test Rest"

      }

    },

    {

      "url": "/data/objects/WorkItemHierarchyLink",

      "method": "PUT",

      "body": {

        "Child": {

          "id": "/Task/ae35cd4b-ed6b-48b5-9ff5-de3da68cf635"

        },

        "Parent": {

          "id": "/Task/0cbc02c2-48d3-4b1c-afa4-857723cb0b4b"

        }

      }

    }

  ]

}

 

The first operation works ok, but the second one fails with the following error:

Can not convert value '{

  "id": "/Task/ae35cd4b-ed6b-48b5-9ff5-de3da68cf635"

}' to type 'ObjectIdentifier' (Field name: 'Child')

 

What am I doing wrong?

 

Thanks in advance.

Fernando Borrego Polo Answered

Please sign in to leave a comment.

4 comments

0
Avatar

Hi Fernando,

First, you no longer need to separately create a link to the parent. When creating new work items, you can specify parent as a field:

 "body": {

        "id": "/Task/ae35cd4b-ed6b-48b5-9ff5-de3da68cf635",

        "Description": "Test Description",

        "Name": "Test Rest",

        "Parent":  "/Task/0cbc02c2-48d3-4b1c-afa4-857723cb0b4b"

Second, you don't need to use "id:" for reference to object fields, this is only relevant when creating a new object, for the object itself. Thus the link creation message should look like this:

 "body": {

        "Child": "/Task/ae35cd4b-ed6b-48b5-9ff5-de3da68cf635",

        "Parent": "/Task/0cbc02c2-48d3-4b1c-afa4-857723cb0b4b"

        }

Hope this helps,

Ophir     

Ophir Kenig 0 votes
Comment actions Permalink
0
Avatar

Hi Ophir,

I finally was able to do a complete test on this and I found out that the hierarchy workflow rules are not triggered when using the method you mentioned (putting the parent reference in the entity to be created instead of creating the link separately). Is this as designed? Because this completely breaks several workflows we had based on the notion of the parent link being created, but at the same time is very convenient not having to create the link separately.

Thanks in advance.

Fernando Borrego Polo 0 votes
Comment actions Permalink
1
Avatar

Hi Fernando,
Great to hear you managed the previous one.
As for the workflow rules, I took my own tests, but it seems the 'Parent' workflow rules DO run, (I particularly tested bulk REST API).

As you've sent detailed information and access to your account in the support ticket you've opened separately (you did a really good job on that!), I could look into the specifics in your account.
I think the workflow rules don't run because the conditions evaluate to false, meaning the Task data you've entered is the cause of the issue.
Specifically I could see the Forecast Task Type is not set. Could you look into the data sent with the API and the workflow rules again?
Hope this helps,
Ophir

Ophir Kenig 1 vote
Comment actions Permalink
0
Avatar

Hi Ophir,

You are right, I had a bug in my code that wasn't populating the "Forecast Task Type" field. Once I fixed that, the workflow rule was triggered as expected and everything went fine.

Thanks for pointing that out and your quick support on this.

Regards.

Fernando Borrego Polo 0 votes
Comment actions Permalink