Legacy Dev Forum Posts

 View Only

Sign Up

Dynamics 365 > data action array

  • 1.  Dynamics 365 > data action array

    Posted 06-05-2025 18:43

    Ali1 | 2021-05-15 10:02:54 UTC | #1

    Hi there I am trying to make post request using JSON to create phone activity in dynamics 365, but it seems my JSON format is not accepted on data action due to have array on the original message .

    the below JSON message trying to make an data action for it . For a phone call the Json message could look like this:

    { "description" : "Lorem ipsem", "directioncode" : true, "leftvoicemail": false, "regardingobjectidaccount@odata.bind" : "/accounts(EA82D93B-CFD9-E711-812D-E0071B6C2F31)", "subject" : "test", "phonecallactivityparties" : [ { "partyidsystemuser@odata.bind" : "/systemusers(5549B1A7-A7CD-4047-84CC-64BA1FF4756F)", "participationtypemask" : 1 }, { "partyid_contact@odata.bind" : "/contacts(4F2D083E-D3D8-E711-812C-E0071B6C2F31)", "participationtypemask" : 2 }] }

    in data action,

    { "title": "Post Request", "description": "A phone number-based request.", "type": "object", "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "description": { "description": " query.", "type": "string" }, "directioncode": { "description": "query.", "type": "boolean" }, "leftvoicemail": { "description": "query.", "type": "boolean" }, "subject": { "description": "AA.", "type": "string" } }, "additionalProperties": true }

    The phonecallactivityparties. array contains two objects with a navigation lookup to the record and a participationtypemask.

    Thanks.


    Jason_Mathison | 2021-05-16 02:55:33 UTC | #2

    Hi Ali,

    Could you post the exact error that you are getting from test mode, along with the correlation or context ID that it displays? That would help us understand the problem you are facing.

    Is the first block of JSON what you are attempting to send to Dynamics? Will it always have 2 entities in the phonecallactivityparties that looks like your example, or will that need to be dynamically generated?

    --Jason


    Ali1 | 2021-05-19 16:26:50 UTC | #3

    Hi Jason

    This is what i am getting from the data action test when i am trying to add phonecallactivityparties

    * Failed Validation of contract.input.inputSchema as a simple properties schema. Must be an Object with properties and no sub-objects. JSON failed schema validation for the following reasons: Schema: # @/properties/properties/patternProperties/^[a-zA-Z][a-zA-Z0-9_-]*$/properties/type. Error location: /properties/phonecall_activity_parties/type. instance value ("object") not found in enum (possible values: ["boolean","integer","null","number","string"])

    Data action header

    { "requestUrlTemplate": "/api/data/v9.0/phonecalls", "requestType": "POST", "headers": { "UserAgent": "PureCloudIntegrations/1.0" }, "requestTemplate": "${input.rawRequest}" }

    and yes will it always have 2 entities in the phonecallactivityparties.


    Jason_Mathison | 2021-05-19 17:16:00 UTC | #4

    Hi Ali,

    That error is saying that your input schema/contract has to be a flat object with no sub-objects or arrays.

    If you need to pass an array of objects to the web service then you will need to reformat your input into the right shape in your request template.

    For example, if you are always going to have 2 parties to report then you might have a partyid1 and partyid2 in your input contract and them insert them into the correct location in your request template.

    --Jason


    Ali1 | 2021-05-23 05:02:26 UTC | #5

    Hi Jason

    thanks for response, could you please make example for the above JSON message .

    { "description" : "Lorem ipsem", "directioncode" : true, "leftvoicemail": false, "regardingobjectidaccount@odata.bind" : "/accounts(EA82D93B-CFD9-E711-812D-E0071B6C2F31)", "subject" : "test", "phonecallactivityparties" : [ { "partyidsystemuser@odata.bind" : "/systemusers(5549B1A7-A7CD-4047-84CC-64BA1FF4756F)", "participationtypemask" : 1 }, { "partyid_contact@odata.bind" : "/contacts(4F2D083E-D3D8-E711-812C-E0071B6C2F31)", "participationtypemask" : 2 }] }

    Thanks


    Jason_Mathison | 2021-05-24 18:02:51 UTC | #6

    Hi Ali,

    I can't build anything without knowing which parts of the request to dynamics are variable and which parts are the same on every request. Please try to build a request template with variables where needed, and an input contract to provide those variables. If you continue to have issues please post an export of your data action (with anything sensitive covered) and a copy and paste of the error that you are getting.

    --Jason


    Ali1 | 2021-05-25 05:14:03 UTC | #7

    Hi Jason

    The data action request shared on post 1. but without phonecallactivityparties.. where i am facing the issue.

    these are the variable. 1.Lorem ipsem 2.true 3./accounts(EA82D93B-CFD9-E711-812D-E0071B6C2F31) 4./systemusers(5549B1A7-A7CD-4047-84CC-64BA1FF4756F) 5./contacts(4F2D083E-D3D8-E711-812C-E0071B6C2F31)

    Thanks


    Jason_Mathison | 2021-05-25 13:42:23 UTC | #8

    Hi Ali,

    I don't see an attempt at creating a request template in any of your posts. You can export an action from either the page listing all of the actions, or from the action summary page. Further documentation about creating a data action: https://help.mypurecloud.com/articles/request-configuration-data-actions/

    To get yourself started you can paste your example object into a tool like https://www.freeformatter.com/json-escape.html to escape your JSON, and then put it into your request template. Once you have that working you can start replacing parts of it with values from your input contract.

    I am happy to help answer questions or solve problems, but I am not able to create your action for you.

    --Jason


    Ali1 | 2021-05-26 05:27:53 UTC | #9

    Here are the data action export. xxx-Post-phone-By-Phone-.custom.json|attachment (4.7 KB)


    Ali1 | 2021-05-26 11:17:46 UTC | #10

    Issue fixed after Creating new template, Thanks Jason


    Jason_Mathison | 2021-05-26 13:26:10 UTC | #11

    That is great news! Congratulations Ali :slight_smile:

    --Jason


    system | 2021-06-26 13:26:12 UTC | #12

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 10927