Genesys Cloud - Main

 View Only

Discussion Thread View
  • 1.  PUT Method in Custom Action (Dynamics 365)

    Posted 02-15-2018 12:21

    Hi,

     

    I have to create a Custom Action to generate into Dynamics CRM a record throught a PureCloud custom action

     

    I tried this:

    Contracts - Input

    {

      "$schema": "http://json-schema.org/draft-04/schema#",

      "description": "Update user's first and/or last name",

      "properties": {

       "ACCOUNT_ID": {

        "description": "User Id",

        "type": "string"

       },

       "NAME": {

        "description": "Users first name",

        "type": "string"

       },

       "LAST_NAME": {

        "description": "User last name",

        "type": "string"

       }

      },

      "required": [

       "ACCOUNT_ID",

       "NAME",

       "LAST_NAME"

      ],

      "title": "Update name request",

      "type": "object"

     }

     

    Contracts - Output

    {

     "properties": {}

    }

     

    Configuration - Request

    {

    "headers": {

        "Content-Type": "application/json",

        "UserAgent": "PureCloudIntegrations/1.0",

        "Company": "My company"

       },

       "requestTemplate" : "{\"firstname\": \"${input.NAME}\",\"lastname\": \"${input.LAST_NAME}\"}",

       "requestType": "POST",

       "requestUrlTemplate": "/api/data/v8.1/accounts/$(input.ACCOUNT_ID)"

      }

     

    Configuration - Response

     

    {

     "translationMap": {

      "account": "$.value"

     },

     "successTemplate": "${account}"

    }

     

    Test

     

    "status": 400,

    "code": "bad.request",

    "message": "The request could not be understood by the server due to malformed syntax.",

     

     

    Thanks

    Sergio



  • 2.  RE: PUT Method in Custom Action (Dynamics 365)

    GENESYS
    Posted 02-15-2018 12:58

    Please try following the directions in this article:

    https://help.mypurecloud.com/articles/custom-action-web-services-data-actions-integration-fails-unexpected-reason/



  • 3.  RE: PUT Method in Custom Action (Dynamics 365)

    Posted 02-15-2018 14:08

    I tried with  "Transfer-Encoding": "buffered" but the error persist

     

    I also change this: "requestUrlTemplate": "https://myorganization.crm4.dynamics.com/accounts/$(input.ACCOUNT_ID)"

     

    (before = /api/data/v8.1/accounts/$(input.ACCOUNT_ID))

     

    The error now is:

     

    "status": 404,

    "code": "not.found",

    "message": "The requested resource was not found.",

     

    Thanks

    Sergio

     



  • 4.  RE: PUT Method in Custom Action (Dynamics 365)

    GENESYS
    Posted 02-15-2018 14:14

    requestUrlTemplate should not include the"https://myorganization.crm4.dynamics.com" as that is handled by your credentials.

     

    I just noticed that the title of this thread indicates that this is a PUT, but your request type is configured as a POST. Is that intentional?



  • 5.  RE: PUT Method in Custom Action (Dynamics 365)

    Posted 02-15-2018 14:30

    Thank you jason for your availability

     

    1) requestUrlTemplate should not include the"https://myorganization.crm4.dynamics.com" as that is handled by your credentials.

     

    If I insert /api/data/v8.1/accounts/$(input.ACCOUNT_ID) the error is 400 (bad request);

    If I insert https://myorganization.crm4.dynamics.com/accounts/$(input.ACCOUNT_ID) the error is 404 (not found)

     

    2) I just noticed that the title of this thread indicates that this is a PUT, but your request type is configured as a POST. Is that intentional?

     

    I now have to replace values (POST); in another test i will put data into Dynamics CRM

     

    Do you have a PUT method example to help me?

    for POST I followed this: https://help.mypurecloud.com/articles/request-configuration-data-actions/

     

    Thanks

     

     



  • 6.  RE: PUT Method in Custom Action (Dynamics 365)

    GENESYS
    Posted 02-15-2018 14:33

    If there is nothing sensitive in your testing, could you post all of the output from test mode, so we can see what the URL, headers, and request body resolve to?



  • 7.  RE: PUT Method in Custom Action (Dynamics 365)

    Posted 02-15-2018 14:48

    Surely!

     

    Output

     

    {

    "status": 400,

    "code": "bad.request",

    "message": "The request could not be understood by the server due to malformed syntax.",

    "messageParams": {},

    "contextId": "17a0720b-28f3-45f4-af04-c357a26fed39",

    "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. [17a0720b-28f3-45f4-af04-c357a26fed39] [17a0720b-28f3-45f4-af04-c357a26fed39]",

    "messageParams": {},

    "details": [],

    "errors": []

    }

    ]

    }

     

     

     

     

    Operazioni

    1. Validate request body contains simple json (key-value pairs)

    {

    "ACCOUNT_ID": "8179FB91-59FC-E711-80F8-3863BB34DB00",

    "NAME": "Luca",

    "LAST_NAME": "Bianchi",

    "orgId": "69710e28-6401-474a-8490-a0455f6a59f2",

    "integrationId": "2daab79d-dcf7-443c-ae51-9b91ed722099",

    "rawRequest": "{\"ACCOUNT_ID\":\"8179FB91-59FC-E711-80F8-3863BB34DB00\",\"NAME\":\"Luca\",\"LAST_NAME\":\"Bianchi\"}"

    }

     

    2. Validate draft definition

     

    {

    "success": true

    }

     

    3. Validate request body against input schema

     

    {

    "success": true

    }

     

    4. Perform authentication

     

    {

    "success": true

    }

     

    5. Resolve request URL template

     

    "[POST] https://testsinergia2.crm4.dynamics.com/api/data/v8.1/accounts/8179FB91-59FC-E711-80F8-3863BB34DB00"

     

    6. Resolve request header templates

     

    {

    "Transfer-Encoding": [

    "buffered"

    ],

    "Authorization": [

    "<REDACTED>"

    ],

    "Company": [

    "My company"

    ],

    "UserAgent": [

    "PureCloudIntegrations/1.0"

    ],

    "Content-Type": [

    "application/json"

    ]

    }

     

    7. Resolve request body template

     

    "{\"name\": \"Luca\",\"sin_codicefiscale\": \"Bianchi\"}"

     

    8. Execute

     

    {

    "status": 400,

    "code": "bad.request",

    "message": "The request could not be understood by the server due to malformed syntax.",

    "messageParams": {},

    "contextId": "17a0720b-28f3-45f4-af04-c357a26fed39",

    "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. [17a0720b-28f3-45f4-af04-c357a26fed39] [17a0720b-28f3-45f4-af04-c357a26fed39]",

    "messageParams": {},

    "details": [],

    "errors": []

    }

    ]

    }

     

     



  • 8.  RE: PUT Method in Custom Action (Dynamics 365)

    Posted 02-15-2018 16:13

    I did IT!!!

     

    I remove Account ID from contract and configuration e the account will create

     

    I tried this:

    Contracts - Input

    {

     "$schema": "http://json-schema.org/draft-04/schema#",

     "title": "Update name request",

     "description": "Update user's first and/or last name",

     "type": "object",

     "required": [

      "NAME",

      "LAST_NAME"

     ],

     "properties": {

      "NAME": {

       "description": "Users first name",

       "type": "string"

      },

      "LAST_NAME": {

       "description": "User last name",

       "type": "string"

      }

     }

    }

     

    Contracts - Output

    {

     "properties": {}

    }

     

    Configuration - Request

     

    {

     "requestUrlTemplate": "/api/data/v8.1/accounts",

     "requestType": "POST",

     "headers": {

      "Content-Type": "application/json",

      "UserAgent": "PureCloudIntegrations/1.0",

      "Company": "My company",

      "Transfer-Encoding": "buffered"

     },

     "requestTemplate": "{\"name\": \"$input.NAME\",\"sin_codicefiscale\": \"$input.LAST_NAME\"}"

    }

     

    Configuration - Response

     

    {

     "translationMap": {},

     "successTemplate": "[${rawResult}]"

    }

     

    Thanks for your availability

    Sorry for my english

    Sergio



  • 9.  RE: PUT Method in Custom Action (Dynamics 365)

    Posted 02-16-2018 05:12

    Another Error =(

     

    I would create a ticket now but in this case:

     

    1. Validate request body contains simple json (key-value pairs)

     

    {

    "title": "boo",

    "orgId": "69710e28-6401-474a-8490-a0455f6a59f2",

    "integrationId": "2daab79d-dcf7-443c-ae51-9b91ed722099",

    "rawRequest": "{\"title\":\"boo\"}"

    }

     

    2. Validate draft definition

     

    {

    "success": true

    }

     

    3. Validate request body against input schema

     

    {

    "success": true

    }

     

    4. Perform authentication

     

    {

    "success": true

    }

     

    5. Resolve request URL template

     

    "[POST] https://testsinergia2.crm4.dynamics.com/api/data/v8.1/incidents"

     

    6. Resolve request header templates

     

    {

    "Transfer-Encoding": [

    "buffered"

    ],

    "Authorization": [

    "<REDACTED>"

    ]

    }

     

    7. Resolve request body template

     

    "{\"title\":\"boo\"}"

     

    8. Execute

     

    {

    "status": 500,

    "code": "internal.server.error",

    "message": "The server encountered an unexpected condition which prevented it from fulfilling the request.",

    "messageParams": {},

    "contextId": "b929e858-d897-4761-b5f4-8957d459e9a0",

    "details": [],

    "errors": [

    {

    "status": 500,

    "code": "INTERNAL_SERVER_ERROR",

    "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. [b929e858-d897-4761-b5f4-8957d459e9a0] [b929e858-d897-4761-b5f4-8957d459e9a0]",

    "messageParams": {},

    "details": [],

    "errors": []

    }

    ]

    }

     

    If I modify the entity in Accounts the Action runs

     

    Thanks



  • 10.  RE: PUT Method in Custom Action (Dynamics 365)

    Posted 02-16-2018 16:11

    It looks like this is the same issue you brought up in a different thread. I recommend that you use a tool like postman and/or MS Dynamics documentation and forums to figure out how to use the Dynamics API. Once you nail down what you are trying to do in Postman the translation to Data Actions is pretty straightforward.



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources