Genesys Cloud (formerly PureCloud)

Discussion Thread View
Expand all | Collapse all

Request Template in Web Service Data Action

Jump to Best Answer
  • 1.  Request Template in Web Service Data Action

    Posted 09-17-2020 10:05
    Hi,

    I'm having trouble with POST, which works fine with API Tester (Chrome extension), but not with Data Action.

    Below is a screen capture that works fine with API Tester.

    Below is the result of trying to do the same with DataAction.

    API Tester works fine, but Data Action gives different results. We have received reports from the linked system that the parameters have not been POSTed.
    Is the Request Template written incorrectly?

    >Contract(input)

    >Configuration(Request)

    Can somebody give me some advice?

    Regards,
    #Integrations

    ------------------------------
    Makoto.Nagai
    Itochu Techno-Solutions Corporation(CTC)
    ------------------------------


  • 2.  RE: Request Template in Web Service Data Action

    Posted 09-17-2020 11:29
    Edited by William Martín Chávez González 09-17-2020 12:33
    Good morning:

    I think you can achieve that by doing the following tasks:

    1. Define a Simple Input Contract with two input data in the schema: both strings, one for the tel and the other for the hash_key.

    The JSON representation of the Input Contract should be like this one:
    {
    "type": "object",
    "required": [
    "tel",
    "hashKey"
    ],
    "properties": {
    "tel": {
    "type": "string"
    },
    "hashKey": {
    "type": "string"
    }
    },
    "additionalProperties": true
    }

    2. Then, you can define a request Body Template like the following:

    {"tel": "${input.tel}", "hash_key": "${input.hashKey}"}

    3. Finally, please put your input data in the Test option and try it again.

    I expect that helps to you.

    ------------------------------
    William Martín Chávez González
    Systems Engineer
    Global Networks Solutions S.A.S.
    ------------------------------



  • 3.  RE: Request Template in Web Service Data Action

    Posted 09-17-2020 11:52
    Hi William,

    Thank you for your reply. Thank you for your help.

    However, I tried it according to your support, but it has not been solved yet.
    Can the Content-Type be "application/json"?

    The result is as follows.
    --
    {
    "message": "Request body is malformed. Error: Invalid numeric value: Leading zeroes not allowed\n at [Source: (String)\"{\"tel\": 09011112222, \"hash_key\": \"c8cd2dc70879f4d0da6c2de3ca620dccb53ec43e7050696ccff252658adc3a94\"}\"; line: 1, column: 10]",
    "code": "internal.server.error",
    "status": 500,
    "messageParams": {},
    "contextId": "9bb61676-e33b-4957-91aa-a4c58cd77e02",
    "details": [
    {
    "errorCode": "ACTION.PROCESSING"
    }
    ],
    "errors": []
    }
    --

    >Contract(input)
    {
    "type": "object",
    "required": [
    "tel",
    "hash_key"
    ],
    "properties": {
    "tel": {
    "type": "string"
    },
    "hash_key": {
    "type": "string"
    }
    },
    "additionalProperties": true
    }

    >Configuration(Request)
    {
    "requestUrlTemplate": "https://stg.tirepit.jp/api/Get_store_name?developerId=loop",
    "requestType": "POST",
    "headers": {
    "Content-Type": "application/json"
    },
    "requestTemplate": "{\"tel\": ${input.tel}, \"hash_key\": \"${input.hash_key}\"}"
    }

    Sorry,


    ------------------------------
    永井誠人
    Itochu Techno-Solutions Corporation(CTC)
    ------------------------------



  • 4.  RE: Request Template in Web Service Data Action

    Posted 09-17-2020 12:01
    Hi:

    Can the Content-Type be "application/json"?: yes, of course. it could be.
    Apparently, you defined the tel input as numeric value, but in your example you showed us that it must be a string value.
    As a result, in the response it says that it is not a valid numeric value because of the leading zeros. That must have happen because it was not a string value that consider that zeros as part of the complete input.
    So, would you please change the input type of tel from numeric to string and try it again, with the same configuration of the other parameters?

    I expect that helps to you.

    ------------------------------
    William Martín Chávez González
    Systems Engineer
    Global Networks Solutions S.A.S.
    ------------------------------



  • 5.  RE: Request Template in Web Service Data Action

    Posted 09-17-2020 12:07
    Hi:

    Also in the response you get it said:
    {
    "message": "Request body is malformed. Error: Invalid numeric value: Leading zeroes not allowed\n at [Source: (String)\"{\"tel\": 09011112222,

    That telephone value was not set as a string value; I think, it should be set like this
    {
    [Source: (String)\"{\"tel\": \"09011112222\" ...

    Please, consider it and try it again.

    ------------------------------
    William Martín Chávez González
    Systems Engineer
    Global Networks Solutions S.A.S.
    ------------------------------



  • 6.  RE: Request Template in Web Service Data Action

    Posted 09-17-2020 12:13
    Hi,

    POST was completed by rewriting the Request Body Template as follows.
    --
    {"tel": "${input.tel}", "hash_key": "${input.hash_key}"}
    --
    As you advised, I changed $ {input.tel} to "$ {input.tel}" to treat it as a String.
    However, the execution result is as follows.
    --
    {
    "status": "False"
    }
    --
    After all, the result of API Tester is not as it is. What's the difference ...

    Sorry,

    ------------------------------
    永井誠人
    Itochu Techno-Solutions Corporation(CTC)
    ------------------------------



  • 7.  RE: Request Template in Web Service Data Action

    Posted 09-17-2020 12:23
    Edited by William Martín Chávez González 09-17-2020 12:23
    Hi:

    Thank you. Yes, you are right about the tel input definition, I forgot to write it between the quotation marks in the Request Body Template, sorry for my mistake.
    Did you consider to do the same request using Postman?

    You could try it and verify the response you expect receive.

    Thank you again.


    ------------------------------
    William Martín Chávez González
    Systems Engineer
    Global Networks Solutions S.A.S.
    ------------------------------



  • 8.  RE: Request Template in Web Service Data Action

    Posted 09-17-2020 12:47
    Hi,

    I ran it with Postman.
    The result worked correctly.



    Can you know the difference from DataAction?

    Sorry,

    ------------------------------
    永井誠人
    Itochu Techno-Solutions Corporation(CTC)
    ------------------------------



  • 9.  RE: Request Template in Web Service Data Action
    Best Answer

    Posted 09-17-2020 12:56
    Hi:

    Thank you.
    Please, check the following links, maybe those could help you:
    1. https://help.mypurecloud.com/articles/custom-action-fails-for-unexpected-reason/
    2. https://help.mypurecloud.com/articles/requirements-for-the-data-actions-integration/ , Web Services Section (confirm the requirements).

    I expect those references can help you.

    ------------------------------
    William Martín Chávez González
    Systems Engineer
    Global Networks Solutions S.A.S.
    ------------------------------



  • 10.  RE: Request Template in Web Service Data Action

    Posted 09-17-2020 13:56
    Hi,

    Completed without incident.
    The cause was "Transfer-Encode: chunked".

    Thanks to your very devoted support, the problem has been resolved.
    Thank you from the bottom of my heart.

    Regards,

    ------------------------------
    永井誠人
    Itochu Techno-Solutions Corporation(CTC)
    ------------------------------



  • 11.  RE: Request Template in Web Service Data Action

    Posted 09-17-2020 18:24
    Hi:

    It was a pleasure to have helped you. That is the purpose.

    I am glad for help you.


    ------------------------------
    William Martín Chávez González
    Systems Engineer
    Global Networks Solutions S.A.S.
    ------------------------------