Legacy Dev Forum Posts

 View Only

Sign Up

Dynamics CE 365 PATCH Custom Data Action - Error 400

  • 1.  Dynamics CE 365 PATCH Custom Data Action - Error 400

    Posted 06-05-2025 18:44

    Ryan_Cheesman | 2022-12-14 20:52:10 UTC | #1

    I am banging my head trying to figure this one out. Have tried every suggestion on this form and elsewhere. Have Gets working just fine. Cannot Patch or Post. Have transfer-encoding set to buffered. I've tried every suggestion for the body and it just won't work. This same API call works fine in Postman.

    REQUEST: { "requestUrlTemplate": "https://t-qa.crm.dynamics.com/api/data/v9.2/phonecalls(${input.ACTIVITYID})", "requestType": "PATCH", "headers": { "authorization": "${authResponse.tokentype} ${authResponse.access_token}", "content-type": "application/json", "transfer-encoding": "buffered" }, "requestTemplate": "{\n \"subject\": \"Test 2\",\n \"description\": \"Test 2\"\n}" }

    RESPONSE: 1. Validate request body contains simple json (key-value pairs): The request could not be understood by the server due to malformed syntax.

    • The value provided in the request body is in the wrong format. Only key-value JSON pairs are supported. Example: {"FirstName" : "Joe", "LastName" : "Williams"}

    POSTMAN BODY:

    {

    "subject": "Test 1",

    "description": "Test 1"

    }

    POSTMAN HEADERS:

    The same client / secret / scope combination is used in PostMan as in what's used in Genesys.


    78692638d4a24645fbf5 | 2022-12-14 21:00:19 UTC | #2

    Can you try a request template that looks like this?

    "requestTemplate": "{\n \"prioritycode\":\"${input.prioritycode}\"\n}"

    That's what I'm using for my Dynamics data action to update an Activity..

    Thanks, Peter


    Jason_Mathison | 2022-12-14 21:36:54 UTC | #3

    It seems to be complaining about the input you are passing to this data action. Can you give us your input contract and your test inputs? Or an export of the action if that is easier and doesn't have anything sensitive.

    --Jason


    Ryan_Cheesman | 2022-12-14 21:56:54 UTC | #4

    I have an update. I created a new action, but exactly the same as the first. The second one works and the first one does not. I cannot find any differences between either. I saw on a seperate thread where the same suggestions where were mentioned, but the poster said they recreated it and it worked for them too. I am wondering if there is a bug behind the scene's preventing it from wroking. I can export both actions if you would like to have a look.

    Maybe it got stuck to the older Auth request I had that was getting a successful token but the wrong token? I had one that didn't specify the scope or resource as it wasn't required in PostMan. I figured it out at one point. So maybe that is it. I cannot tell since you cannot "view" the auth settings once saved. That's my running theory.


    Ryan_Cheesman | 2022-12-16 12:02:27 UTC | #5

    It says new users cannot upload attachments. So I will past my exports here for you.

    { "name": "Set Phone Call - Credit Pull Customer Response (BROKEN) - Exported 2022-12-14 @ 13:58", "integrationType": "custom-rest-actions", "actionType": "custom", "config": { "request": { "requestUrlTemplate": "https://tandemdiabetes-qa.crm.dynamics.com/api/data/v9.2/phonecalls(${input.ACTIVITYID})", "requestType": "PATCH", "headers": { "Authorization": "${authResponse.tokentype} ${authResponse.accesstoken}", "Content-Type": "application/json", "Transfer-Encoding": "buffered" }, "requestTemplate": "{\n \"subject\": \"Test 2\",\n \"description\": \"Test 2\"\n}" }, "response": { "translationMap": {}, "translationMapDefaults": {}, "successTemplate": "${rawResult}" } }, "contract": { "input": { "inputSchema": { "default": "311732ef-7408-ed11-82e4-002248217afd", "type": "object", "properties": { "ACTIVITYID": { "default": "311732ef-7408-ed11-82e4-002248217afd", "type": "string" } }, "additionalProperties": true } }, "output": { "successSchema": { "type": "object", "properties": {}, "additionalProperties": true } } }, "secure": false }

    { "name": "Set Phone Call - Credit Pull Customer Response (WORKING) - Exported 2022-12-14 @ 13:57", "integrationType": "custom-rest-actions", "actionType": "custom", "config": { "request": { "requestUrlTemplate": "https://tandemdiabetes-qa.crm.dynamics.com/api/data/v9.2/phonecalls(${input.ACTIVITYID})", "requestType": "PATCH", "headers": { "Authorization": "${authResponse.tokentype} ${authResponse.accesstoken}", "Content-Type": "application/json", "Transfer-Encoding": "buffered" }, "requestTemplate": "{\n \"subject\": \"Test 2\",\n \"description\": \"Test 2\"\n}" }, "response": { "translationMap": {}, "translationMapDefaults": {}, "successTemplate": "${rawResult}" } }, "contract": { "input": { "inputSchema": { "type": "object", "properties": { "ACTIVITYID": { "default": "311732ef-7408-ed11-82e4-002248217afd", "type": "string" } }, "additionalProperties": true } }, "output": { "successSchema": { "type": "object", "properties": {}, "additionalProperties": true } } }, "secure": false }


    Jason_Mathison | 2022-12-16 12:22:07 UTC | #6

    Hi Ryan,

    I pulled in your actions and reproduced the issue that you are having with the broken action. Thank you for the exports!

    The test is failing during the first step of action execution, where we make sure that the input you send us is only key/"primitive value" pairs (primitive values like strings, numbers, booleans, not objects). Because the test UI is driving this, this step "never fails" in the test UI... but your broken action managed to fail here!

    I opened up the Chrome Developer tools to see what was happening. When trying to test this action the UI is sending the following body when hitting the test execution route:

    {"undefined":{},"ACTIVITY_ID":"311732ef-7408-ed11-82e4-002248217afd"}

    The "undefined":{} is causing this to fail, as that is a key/object. Digging back into your export, there are a two different places that have: ` "default": "311732ef-7408-ed11-82e4-002248217afd"` The one at the root level of the object doesn't make any sense, and is causing the problem. Removing that got the action working.

    I will submit a bug to handle this situation better in the future.

    Thank you for the puzzle :) --Jason


    system | 2023-01-16 12:22:08 UTC | #7

    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: 17653