Genesys Cloud - Developer Community!

 View Only

Sign Up

  • 1.  Site Number Plan Update Fails - SDK Mismatch

    Posted 20 days ago

    Hi,

    The PUT /api/v2/telephony/providers/edges/sites/{siteId}/numberplans endpoint in the API explorer lists the parameters it requires as being in the following format:

    [
      {
        "name": "",
        "division": "",
        "description": "",
        "version": 0,
        "match": "",
        "normalizedFormat": "",
        "priority": 0,
        "numbers": [
          {
            "start": "",
            "end": ""
          }
        ],
        "digitLength": "",
        "classification": "",
        "matchType": ""
      }
    ]

    along with various other useful parameters such a state, etc.

    When trying to access this via the SDK, the method signature is much more restricted, offering only a site ID and a list of number plans (in the  Java SDK).

    I have attempted to use the SDK version to perform an update, but have only succeeded in getting a 400 response, despite supplying what I think is valid data.

    Why the difference between the two, and how can I update number plans via the SDK?


    #PlatformAPI
    #PlatformSDK

    ------------------------------
    Austen Jackson
    Software Architect
    ------------------------------


  • 2.  RE: Site Number Plan Update Fails - SDK Mismatch

    Posted 16 days ago
    Hello,

    The API Explorer displays the information coming from the Platform API Swagger definition (https://api.mypurecloud.com/api/v2/docs/swagger). The Swagger is the description of the Platform API (REST API) - listing available API Endpoints, their input and output contracts.

    The SDKs (Java, Javascript, Python, ...) are generated based on this Swagger definition.
    So, the API Explorer and Java SDK are in fact giving access to the same thing.

    * the siteId (a path parameter)
    * the request body - which is a list of NumberPlans (NumberPlan is an object/class)

    The reason why API Explorer shows name, division, description, ... (when you load an empty schema) is because it is just showing what's available in the NumberPlan model/class (I mean "resolving" and displaying the properties of a NumberPlan class instance).
    In Java code, you would create a NumberPlan instance. Then create a list of NumberPlans (and add the NumberPlan you created to that list). And pass this as parameter of the putTelephonyProvidersEdgesSiteNumberplans method.
    So in both case, it is two parameters - a siteId and a list of NumberPlans. The API Explorer is just allowing you to see in one shot what properties are available in the NumberPlan class.

    The reason why state, dateCreated, dateModified, ... are available properties in the NumberPlan class, but not showing up in API Explorer when used in the request body, is because these properties are read-only.
    Values for such read-only properties are provided in API Responses. But tagging them as read-only means that that they are not read/taken into account if you use and set them for an API request body.

    Here is the NumberPlan model definition in the Swagger:

    "NumberPlan": {
    "type": "object",
    "required": [
    "name"
    ],
    "properties": {
    "id": {
    "type": "string",
    "description": "The globally unique identifier for the object.",
    "readOnly": true
    },
    "name": {
    "type": "string",
    "description": "The name of the entity."
    },
    "division": {
    "description": "The division to which this entity belongs.",
    "$ref": "#/definitions/Division"
    },
    "description": {
    "type": "string",
    "description": "The resource's description."
    },
    "version": {
    "type": "integer",
    "format": "int32",
    "description": "The current version of the resource."
    },
    "dateCreated": {
    "type": "string",
    "format": "date-time",
    "description": "The date the resource was created. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss[.mmm]Z",
    "readOnly": true
    },
    "dateModified": {
    "type": "string",
    "format": "date-time",
    "description": "The date of the last modification to the resource. Date time is represented as an ISO-8601 string. For example: yyyy-MM-ddTHH:mm:ss[.mmm]Z",
    "readOnly": true
    },
    "modifiedBy": {
    "type": "string",
    "description": "The ID of the user that last modified the resource.",
    "readOnly": true
    },
    "createdBy": {
    "type": "string",
    "description": "The ID of the user that created the resource.",
    "readOnly": true
    },
    "state": {
    "type": "string",
    "description": "Indicates if the resource is active, inactive, or deleted.",
    "readOnly": true,
    "enum": [
    "active",
    "inactive",
    "deleted"
    ]
    },
    "modifiedByApp": {
    "type": "string",
    "description": "The application that last modified the resource.",
    "readOnly": true
    },
    "createdByApp": {
    "type": "string",
    "description": "The application that created the resource.",
    "readOnly": true
    },
    "match": {
    "type": "string"
    },
    "normalizedFormat": {
    "type": "string"
    },
    "priority": {
    "type": "integer",
    "format": "int32"
    },
    "numbers": {
    "type": "array",
    "items": {
    "$ref": "#/definitions/Number"
    }
    },
    "digitLength": {
    "$ref": "#/definitions/DigitLength"
    },
    "classification": {
    "type": "string"
    },
    "matchType": {
    "type": "string"
    },
    "selfUri": {
    "type": "string",
    "format": "uri",
    "description": "The URI for this object",
    "readOnly": true
    }
    }
    },

    The corresponding NumberPlan in Java SDK is defined in the SDK doc: https://mypurecloud.github.io/platform-client-sdk-python/NumberPlan

    I just noticed that the fact the property is read-only does not show up in the SDK doc. I'll see if I can improve this in the future.

    Now, regarding your 400 error response.
    I think it is probably due to the formatting of the body for certain parameters (for NumberPlan).
    I just noticed a glitch in API Explorer. If you click in Load empty schema (I guess that's what you did to see available parameters - i.e. Number Plan available properties/parameters), it does not display the right format for two parameters on first click (division and digitLength). Click a second time on Load Empty schema, it will then display the right format for division and digitLength:
    [
    {
    "name": "",
    "division": {
    "name": ""
    },
    "description": "",
    "version": 0,
    "match": "",
    "normalizedFormat": "",
    "priority": 0,
    "numbers": [
    {
    "start": "",
    "end": ""
    }
    ],
    "digitLength": {
    "start": "",
    "end": ""
    },
    "classification": "",
    "matchType": ""
    }
    ]

    I will report this to the team in charge of API Explorer.

    If you can tell me what body content you are trying to send (or what you are trying to modify in a NumberPlan you retrieved via a GET), I can probably try to help you to shape it correctly in Java SDK.

    Regards,


    ------------------------------
    Jerome Saint-Marc
    Senior Development Support Engineer
    ------------------------------