My objective is to create one Expense Sheet per project and add Expense items per month from an external system.
PART 1: CREATING A NEW EXPENSE SHEET AND SET DEFAULT PROJECT
curl -H "Authorization: Session f45185ff-c5cf-46f7-a40c-0f6ce9d9b958_23596289"https://api2.clarizen.com/v2.0/services/data/createAndRetrieve -d "{entity:{Id:'/ExpenseSheet',Description:'New Expense Sheet Created by Clarizen API',Date:'2016-06-30',project:{externalid:'/Project/68ca3ebilvkxchy11qddm8mid4243'}},fields:['CreatedOn','ExternalId']}"
However, I get below error
{"errorCode":"General","message":"Can not convert value '{\r\n \"externalid\":\"/Project/68ca3ebilvkxchy11qddm8mid4243\"\r\n}' to type 'Entity' (Field name: 'Value')","referenceId":"1U3LupwnLVgGH8jAFMiVmd"}
Worth to mention is that a separate call on the object itself works:
curl -H "Authorization: Session f45185ff-c5cf-46f7-a40c-0f6ce9d9b958_23596289"https://api2.clarizen.com/v2.0/services/data/objects/ExpenseSheet/1m455c1pq0dw4fkr0pzubyx4t44 -d "{project:'/Project/68ca3ebilvkxchy11qddm8mid4243'}"
PART 2: ADDING AN EXPENSE UNDER AN EXPENSE SHEET
curl -H "Authorization: Session f45185ff-c5cf-46f7-a40c-0f6ce9d9b958_23596289"https://api2.clarizen.com/v2.0/services/data/createAndRetrieve -d "{entity:{Id:'/Expense',Description:'New Expense Created by Clarizen API',DateIncurred:'2016-06-30',LocalAmount:{currency:'JPY',value:1234567.0},ExpenseSheet:{externalid:'/ExpenseSheet/1m455c1pq0dw4fkr0pzubyx4t44'}},fields:['CreatedOn','ExternalID']}"
This time as well, I get an error
{"errorCode":"General","message":"Can not convert value '{\r\n \"externalid\":\"/ExpenseSheet/1m455c1pq0dw4fkr0pzubyx4t44\"\r\n}' to type 'Entity' (Field name: 'Value')","referenceId":"1hm4KeLo5f3vsBTvafVIfr"}
If I don't set Expense Sheet when creating the Expense item, a new Expense Sheet will automatically created as Parent. And, it is not possible to update the field 'ExpenseSheet' after the Expense is created.
Any suggestions about how I can achieve below objective is highly thankful.
1. Create a new Expense Sheet and set project name (called Default Project)
2. Add new Expenses to the created Expense Sheet