mmcclellan | 2018-02-02 20:16:03 UTC | #1
I've been trying to create a custom data action using the Dynamics 365 plugin (cloud not bridge) - it's a simple one - create Account. I get the same response every time. Here's the setup:
Input Contract:
{ "$schema": "http://json-schema.org/draft-04/schema#", "title": "Create Account Request", "description": "Create an account on Dynamics 365", "type": "object", "required": [ "NAME" ], "properties": { "NAME": { "type": "string", "description": "The account name." } } }
Config:
{ "requestUrlTemplate": "/api/data/v8.1/accounts", "requestType": "POST", "headers": {}, "requestTemplate": "${input.rawRequest}" }
That's it.
When I test,
URL template resolves: "[POST] https://dartcontainers.crm.dynamics.com/api/data/v8.1/accounts" Request body resolves: "{\"NAME\":\"The Test Account\"}"
But upon execution I get:
{ "status": 400, "code": "bad.request", "message": "The request could not be understood by the server due to malformed syntax.", "messageParams": {}, "contextId": "589938a2-372b-4b24-a3ed-c35f4edf146e", "details": [], "errors": [ { "status": 400, "code": "BAD_REQUEST", "message": "REST call for action execute failed. Message:Request to backend service failed. To see error details, execute request in Postman, or other REST tools. [589938a2-372b-4b24-a3ed-c35f4edf146e] [589938a2-372b-4b24-a3ed-c35f4edf146e]", "messageParams": {}, "details": [], "errors": [] } ] }
every single time - driving me crazy. I can run this and many more complex POSTs in Postman all day - but every POST I create in a custom data action returns this....
Thoughts?
--Matt
ChrisDibble | 2018-02-02 22:24:21 UTC | #2
Hi Matt.
TL;DR - Add this header to your config
"Transfer-Encoding": "buffered"
Then refresh your page, and your test execution should work.
Longer explanation- You're running into an issue with the transfer encoding. Dynamics does not like chunked transfer encoding, which is the http standard default since 1.1. We support overriding that encoding by specifying the header above. You should add this for any request for Dynamics that contains a body.
We automatically change the encoding for the authentication request, but failed to have the action requests inherit that property. The GET requests work fine because they don't have bodies. I've created a ticket for the encoding to be inherited based on the integration type, but it will take some time to implement. In the meantime, setting that header value should get you up and running.
-Chris
mmcclellan | 2018-02-03 01:05:51 UTC | #3
I even saw that article and dismissed that (so didn't try it).
Chris FTW.
It works - thanks!
--Matt
SergioRota | 2018-02-16 11:59:17 UTC | #4
Hi Matt and Chris,
I've been tryin to create Account throught the custom action and It works, but If I try to change entity in incident and try to create a Ticket a error occurs:
"status": 500, "code": "internal.server.error", "message": "The server encountered an unexpected condition which prevented it from fulfilling the request.",
This is my custom action:
Input Contract: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "Richiesta di creazione Ticket", "description": "Crea Ticket con Titolo", "type": "object", "required": [ "title" ], "properties": { "title": { "description": "Titolo del Ticket", "type": "string" } } }
Config:
{ "requestUrlTemplate": "/api/data/v8.1/incidents", "requestType": "POST", "headers": { "type": "text/plain", "Transfer-Encoding": "buffered" }, "requestTemplate": "${input.rawRequest}" }
Thanks Sergio
Jason_Mathison | 2018-02-16 12:29:28 UTC | #5
This header could be causing you trouble:
“type”: “text/plain”,
SergioRota | 2018-02-16 13:25:37 UTC | #6
I remove It and I insert "Content-Type": "application/json" but the error persists
Jason_Mathison | 2018-02-16 20:53:27 UTC | #7
A fix is being deployed this weekend for the issue with MS Dynamics POST messages requiring a "Transfer-Encoding" header. Once the fix is in place that header will be implicitly set for all MS Dynamics actions.
Sergio, googling around a bit, this page may give you what you need. https://community.dynamics.com/crm/f/117/t/228949
In general, our recommendation is to use a tool like postman to figure out how to use an API and get to the point where you know exactly what you want to do. The Data Action service doesn't return failure responses, making it a poor tool to use for experimentation.
SergioRota | 2018-02-19 08:42:09 UTC | #8
Thanks Jason!
I have Postman but how can I insert the schema created in PureCloud? I have my Custom Action but I don't know how to put it in Postman
Sergio
Jason_Mathison | 2018-03-07 15:54:46 UTC | #9
Sergio, were you able to figure this out? If not, can you post what you have that is not working?
SergioRota | 2018-03-07 16:19:34 UTC | #10
Yes, I will delete my answer
Thanks Sergio
system | 2018-04-07 16:19:36 UTC | #11
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: 2461