0

I am trying to POST the below json using the Microsoft Dynamics WebAPI. The post returns a success, but in my data the ccseq_employeeid and ccseq_clientid are not set. What do I need to change to get the fields to post correctly?

Entity Structure

ccseq_expensetransaction has a lookup to ccseq_expensetransactionsets with a relationship that has the name ccseq_ccseq_expensetransactionset_ccseq_expensetransaction_ExpenseTransactionSetID. The lookups to systemusers and ccseq_clients are a part of the ccseq_expensetransaction entity.

Code

POST /api/data/v8.0/ccseq_expensetransactionsets HTTP/1.1
Host: url.com
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 24f7ead3-0307-996f-f45a-f959c604c922

{
   "ccseq_importdate":"2017-06-05T04:00:00Z",
   "ccseq_month":"1",
   "ccseq_year":"2017",
   "ccseq_name":"Test 30",
   "ccseq_status":"100000000",
   "ccseq_ccseq_expensetransactionset_ccseq_expensetransaction_ExpenseTransactionSetID":[
      {
         "ExpenseTransaction[ccseq_employeeid@odata.bind]":"/systemusers(6d2fd71b-32d1-dd11-a4f5-001a6449bbe7)",
         "ExpenseTransaction[ccseq_clientid@odata.bind]":"/ccseq_clients(663ebd00-73b9-4faf-90ed-f56bb9c2dc9b)"
      }
   ]
}
Tim Hutchison
  • 3,483
  • 9
  • 40
  • 76

1 Answers1

0

Modify the body of the request into this:

{
   "ccseq_importdate": "2017-06-05T04:00:00Z",
   "ccseq_month": "1",
   "ccseq_year": "2017",
   "ccseq_name": "Test 30",
   "ccseq_status": "100000000",
   "ccseq_employeeid@odata.bind": "/systemusers(6d2fd71b-32d1-dd11-a4f5-001a6449bbe7)",
   "ccseq_clientid@odata.bind": "/ccseq_clients(663ebd00-73b9-4faf-90ed-f56bb9c2dc9b)"
}
Henk van Boeijen
  • 7,357
  • 6
  • 32
  • 42
  • This doesn't work for me. I believe it's because the `systemusers` and `ccseq_clients` lookups are on the child entity `ccseq_expensetransaction`. See my updated question for the details of my entity structure. – Tim Hutchison Jul 05 '17 at 17:52
  • As far as I know it is not possible to update fields on related entities in one and the same request. – Henk van Boeijen Jul 05 '17 at 18:26