Genesys Cloud - Main

 View Only

Sign Up

  Thread closed by the administrator, not accepting new replies.
  • 1.  Custom Web Service Action, returns string OR null

    Posted 11-05-2018 16:24
    No replies, thread closed.
    I have a custom web service action which can return an address field as either a string or a null for example:

    String...
    {
       "address": "123 sesame st."
    }

    null...
    {
       "address": null
    }


    If I set the data type on the output contract to "string", then we get back a null, then we get a "JSON failed schema validation error".

    Is there a way to set up my contract so both responses will work?
    #Integrations

    ------------------------------
    Hal Nordlin
    Avtex
    ------------------------------


  • 2.  RE: Custom Web Service Action, returns string OR null

    Posted 11-06-2018 10:06
    No replies, thread closed.

    You're going to want to use the translation map defaults section of your response configuration to handle this.  This will return your configured default value in the event the web service doesn't return a value for the defined attribute.  

    https://help.mypurecloud.com/articles/response-configuration-data-actions/



    ------------------------------
    Richard Schott
    Genesys - Employees
    ------------------------------



  • 3.  RE: Custom Web Service Action, returns string OR null

    Posted 11-07-2018 11:41
    No replies, thread closed.
    Thanks, Richard I will try that.

    I also found after I posted this question, that you can supply multiple types in the output contract, which also seems to have resolved my issue. So instead of specifying "type": "string", I specified "type": ["string"<g class="gr_ gr_241 gr-alert gr_gramm gr_inline_cards gr_run_anim Style replaceWithoutSep" id="241" data-gr-id="241">,"</g>null"], which allowed the null to be returned from the service.

    Here's an example of my definition. In my <g class="gr_ gr_285 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" id="285" data-gr-id="285">case</g> this was an array of strings that can optionally return null.


    "address": {
       "type": "array",
       "items": {
          "type": [ "string","null"]
       }
    }

    ------------------------------
    Hal Nordlin
    Avtex
    ------------------------------



  • 4.  RE: Custom Web Service Action, returns string OR null

    Posted 11-08-2018 09:14
    No replies, thread closed.
    That will work too.  Just remember that if you map that value somewhere in the call flow itself, you'll need to do a null check, or else the call flow will throw an error and take the default error handling path configured on the flow (which can be set to "hang up").  Using the translation map default will allow you to still present some value for your attribute, which the call flow can continue to process.

    ------------------------------
    Richard Schott
    Genesys - Employees
    ------------------------------