Legacy Dev Forum Posts

 View Only

Sign Up

Square Brackets in Key Causing Web Services Data Action to not be Valid

  • 1.  Square Brackets in Key Causing Web Services Data Action to not be Valid

    Posted 06-05-2025 18:43

    Dan_Fontaine | 2022-08-24 20:50:52 UTC | #1

    I am working with the Documo Fax API and the send Fax API call has the following key: "attachmentUrls[]" which has square brackets in it. When I create the Input Contract in Genesys Cloud (even though the key name is a string) it thinks that I am trying to create an Object/Array.

    { "type": "object", "properties": { "faxNumber": { "type": "string" }, "coverPage": { "type": "boolean" }, "coverPageId": { "type": "string" }, "recipientName": { "type": "string" }, "attachmentUrls[]": { "type": "string" } }, "additionalProperties": true }

    Is this a bug? Or, is there something that I need to do to escape the bracket characters?

    The documentation for the Send Fax API is here: https://docs.documo.com/#4c501802-7d0b-4e70-98ef-64249d3606fb


    Jason_Mathison | 2022-08-25 13:07:57 UTC | #2

    Hi Dan,

    It isn't exactly a bug. We limit the characters used in the input contract variable names to something like A-Z 0-9 - $ and a few other 'reasonable' characters. That list does not contain square brackets. However, when you are configuring the request that is going to be sent to your API you can use whatever you want. So remove the [] form the input contract and then in your request template have something like "attachmentUrls[]" : "${attachmentUrls}"

    --Jason


    Dan_Fontaine | 2022-08-25 17:22:38 UTC | #3

    Okay, that did solve the use of the square bracket in the UI.

    { "requestUrlTemplate": "https://api.sandbox.documo.com/v1/faxes", "requestType": "POST", "headers": { "Authorization": "Basic REMOVED" }, "requestTemplate": "{\"faxNumber\": \"${input.faxNumber}\",\"coverPage\": true,\"coverPageId\": \"${input.coverPageId}\",\"recipientName\": \"${input.recipientName}\",\"attachmentUrls[]\": \"${input.attachmentUrls}\"}" }

    Now it seems to ignore the attachmentUrls[] item - the service is treating it as an extra key/value pair when I run this from Genesys Cloud. If I run it in postman the key is recognized and the value is assigned. I have tested this extensively just to be sure.

    Postman:

    curl --location --request POST 'https://api.sandbox.documo.com/v1/faxes' \ --header 'Authorization: Basic REMOVED' \ --form 'faxNumber="16027971635"' \ --form 'coverPage="true"' \ --form 'coverPageId="d1f3b7fc-e520-44e2-8f9e-f6411122e79d"' \ --form 'recipientName="16027971635"' \ --form 'attachmentUrls[]="https://removedURL/file.pdf"'

    Thanks, Dan


    Jason_Mathison | 2022-08-25 17:49:46 UTC | #4

    Hey Dan,

    It appears that in the data action you are sending json to the endpoint { "faxNumber": "555-1212" .... }

    but in postman you are sending form data. faxNumber="5551212"&foo=bar...

    If you look at postman console on a request you should see how that is formatted and be able to replicate it in your data action. You might also need to set a header to indicate that you are sending form encoded content.

    --Jason


    Dan_Fontaine | 2022-08-25 20:25:47 UTC | #5

    Sorry, I should have said that I can send a fax from Genesys Cloud. I can set the Fax with a specific Cover Letter, and Recipient -- works great from Genesys Cloud. What I couldn't do was attach the files with attachUrls[].

    BUT UPDATE: There was missing documentation that I received thru Documo support. The correct structure for JSON for the attached files is:

    "attachmentUrls": ["<url in here>"]

    So, I still did do as you suggested with the Request Configuration:

    ` "requestTemplate": "{\"faxNumber\": \"${input.faxNumber}\",\"coverPage\": true,\"coverPageId\": \"${input.coverPageId}\",\"recipientName\": \"${input.recipientName}\", \"attachmentUrls\": [\"${input.attachmentUrls}\"]}"`

    And, now it works. Thanks @Jason_Mathison.

    If anyone is looking to automate sending a fax from Genesys Cloud (without user context) this may be a solution for you. Still looking into other vendors though.


    system | 2022-09-25 20:26:44 UTC | #6

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