REST API: How To Add Cost Plan Details
search cancel

REST API: How To Add Cost Plan Details

book

Article ID: 262425

calendar_today

Updated On:

Products

Clarity PPM On Premise

Issue/Introduction

The REST API error shows when trying to POST cost plan details data.

{

"resourceId":null,
"httpStatus":"500",
"errorMessage":"An exception occurred while trying to update an object instance z_finance",
"errorCode":"api.internalError"
}

 

Environment

Release : 16.1.0

Resolution

The resource and values can be added in 2 steps:

1. Add the resource to the cost plan details

POST
/ppm/rest/v1/costPlans/5009000/costPlanDetails

{
    "_internalId": "__newlyAdded_96146549",
    "investmentId": 5022027,
    "resource": "5005012"
}

2. Add the values

PUT
/ppm/rest/v1/costPlans/5009000/costPlanDetails

{
    "d": [
        {
            "cost": {
                "workEffortUnit": "hours",
                "pattern": "uniform",
                "periodList": [
                    {
                        "periods": [
                            {
                                "start": "2023-03-01T00:00:00",
                                "finish": "2023-03-31T00:00:00",
                                "value": 12.11
                            }
                        ]
                    }
                ]
            },
            "_internalId": 5056012
        }
    ],
    "_metadata": {
        "fields": "resource,cost,cost,units,units,_isFavorite"
    }
}

Additional Information

POST

/ppm/rest/v1/costPlans/5009000/costPlanDetails/

{
    "resource": "5005012",
    "investmentId": 5022027,
    "units": {
        "isFiscal": true,
        "curveType": "value",
        "total": 30,
        "dataType": "numeric",
        "_type": "tsv",
        "start": "2023-03-01T00:00:00",
        "finish": "2023-04-30T00:00:00",
        "segmentList": {
            "total": 30,
            "defaultValue": 0,
            "segments": [
                {
                    "start": "2023-03-01T00:00:00",
                    "finish": "2023-03-31T00:00:00",
                    "value": 10
                },
                {
                    "start": "2023-04-01T00:00:00",
                    "finish": "2023-04-30T00:00:00",
                    "value": 20
                }
            ]
        }
    },
    "cost": {
        "isFiscal": true,
        "curveType": "value",
        "total": 30.3,
        "dataType": "numeric",
        "_type": "tsv",
        "start": "2023-03-01T00:00:00",
        "currency": "USD",
        "finish": "2023-04-30T00:00:00",
        "segmentList": {
            "total": 30.3,
            "defaultValue": 0,
            "segments": [
                {
                    "start": "2023-03-01T00:00:00",
                    "finish": "2023-03-31T00:00:00",
                    "value": 10.1
                },
                {
                    "start": "2023-04-01T00:00:00",
                    "finish": "2023-04-30T00:00:00",
                    "value": 20.2
                }
            ]
        }
    }
}