Spendint API - POST /sn_spend_intg/spendint/availability

  • Release version: Xanadu
  • Updated August 1, 2024
  • 2 minutes to read
  • Summarize
    Summarized using AI
    This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.

    Summary of Spendint API - POST /snspendintg/spendint/availability

    The Spendint API's POST /snspendintg/spendint/availability endpoint enables ServiceNow customers to update the availability of supplier product records. This API uses the product SKU to identify existing supplier products and updates theiravailableunitsfield accordingly. If a product SKU does not match an existing supplier product, the API returns an error indicating the product does not exist.

    Show full answer Show less

    Key Features

    • Update Availability: Modify the available units for supplier products based on SKU and unit of measure.
    • Support for Bulk Updates: Allows updating availability for up to 1000 products in a single request.
    • Asynchronous and Synchronous Modes: Choose between async (default) and sync modes to suit integration needs.
    • Error Reporting: Access detailed error information per SKU when updates fail, including error messages on missing products or data formatting issues.
    • Status Tracking: Use the ServiceNow Table REST API to query the Availability Error and Outbound Status tables for details on failed update requests.

    Request Parameters and Usage

    • Required Fields: catalogid, customerid, products array (each with sku, unit, and availableunits).
    • Optional Fields: supplierid to identify the supplier/reseller, and thirdpartyimportid to uniquely identify imported data sets.
    • Headers: Set Accept header to application/json (default and only supported format for Procurement Integration Framework).
    • Mode Query Parameter: Specify async (default) or sync to control request processing behavior.

    Response and Error Handling

    • Success Response: Returns a simple JSON object with response: "success".
    • Error Response: Returns detailed error messages per SKU when updates fail, including reasons such as non-existent products or formatting issues.
    • Status Codes: success for successful processing, failure for errors.

    Status Monitoring

    To monitor update request statuses, query the ServiceNow database using the Table REST API on the Availability Error table filtered by supplierid and error state. Parent error details are available in the Outbound Status table including customer ID, supplier ID, error type, and import set ID.

    Practical Impact for ServiceNow Customers

    This API allows customers to maintain accurate, real-time inventory levels for supplier products within ServiceNow. Ensuring availability data is current enables better procurement decisions and order fulfillment. The support for bulk updates and detailed error reporting facilitates integration with third-party systems and helps quickly identify and resolve data issues.

    Updates the availability for supplier product records.

    When supplier product records are available, the API uses the product SKU to find an existing supplier product. If a matching supplier product exists, the corresponding available_units field is updated. If no matching supplier product is found, an error message generates stating that the product for which you are trying to update availability for does not exist.

    Status tables

    To know the status of the update availability request, make a REST call into the ServiceNow database using the Table REST API. The response from the API lists the records where the update availability request failed. For update availability response, query the Availability Error table with the following parameter:

    sysparm_query=outbound_error.supplier_id=<supplier_id>^outbound_error.state=20

    The details on the customer ID, supplier ID, error type, unique import set ID, and state can be found in the Outbound Status table, which is the parent error table.

    URL format

    /api/sn_spend_intg/spendint/availability

    Supported request parameters

    Table 1. Path parameters
    Name Description
    None
    Table 2. Query parameters
    Name Description
    mode Support for asynchronous and synchronous modes for third-party integration.

    Data type: String

    Valid values:
    • async: Asynchronous mode.
    • sync: Synchronous mode.

    Default: async

    Table 3. Request body parameters (XML or JSON)
    Name Description
    catalog_id Required. Identifier for the catalog content that can be purchased by a customer.

    Data type: String

    Maximum length: 100

    customer_id Required. Identifier for the customer.

    Data type: String

    Maximum length: 100

    products List of objects that define the products to update. Each transaction has a limit of 1000 products.

    Data type: Array

    "products": [
      {
        "available_units": "String",
        "sku": "String",
        "unit": "String"
      }
    ]
    products.available_units Required for products that are kept in stock. Number of units available for this product.

    Data type: String

    Maximum length: 40

    products.sku Required. Number that is generated by a supplier that uniquely identifies a product sold by that supplier.

    Data type: String

    Maximum length: 100

    products.unit Required. Unit or rate at which the product is sold by the supplier. For example, pieces, hours, and so on.

    Data type: String

    Maximum length: 100

    supplier_id Identifier for the reseller or supplier that the customer can place orders with.

    Data type: String

    Maximum length: 100

    third_party_import_id Allows a third-party to pass a string value to uniquely identify a set of imported data.

    Data type: String

    Maximum length: 100

    Headers

    The following request and response headers apply to this HTTP action only or apply to this action in a distinct way.

    Table 4. Request headers
    Header Description
    Accept Data format of the response body. Supported types: application/json or application/xml.

    Default: application/json

    Note:
    Only the application/json data format is supported for Procurement Integration Framework.
    Table 5. Response headers
    Header Description
    None

    Status codes

    The following status codes apply to this HTTP action.

    Table 6. Status codes
    Status code Description
    success Successful. The request was successfully processed.
    failure Unsuccessful. The request was processed with errors.

    Response body parameters (JSON)

    These response body parameters are received when queried in synchronous mode.
    Name Description
    error_response_body Description of the errors, listed by sku and the error message.

    Data type: Array

    error_response_body.error_message Detailed error message.

    Data type: String

    status_code Response status such as "success" or "failure."

    Data type: String

    cURL request

    curl "https://instance.servicenow.com/api/sn_spend_intg/spendint/availability" \
    --request POST \
    --header "Accept:application/json" \
    --user 'username':'password'
    {"root": [{
      "customer_id": "AB-1234323",
      "catalog_id": "ACME CORP",
      "supplier_id": "SUP-123456",
      "third_party_import_id": "DEL6789876",
      "products": [
        {
          "sku": "5578874",
          "unit": "Each",
          "available_units": "20"
        }
      ]
    }
    ]}
    

    Possible responses:

    // Success response:
    {
        "result": {
            "response": "success"
        }
    }
    
    Error response: 
    {
        "result": {
            "response": [
                {
                    "customer_id": "AB-1234323",
                    "supplier_id": "SUP-123456",
                    "third_party_import_id": "DEL6789876",
                    "status_code": "failure",
                    "error_response_body": [
                        {
                            "sku": "5578874",
                            "error_message": "The product for which you are trying to update availability does not exist\nField Value empty/Formatting issue Unit\n"
                        }
                    ]
                }
            ]
        }
    }