Creating and Publishing an Event with the Event Management API

This procedure describes how to use the Event Management API to create and edit an event.

Prerequisites

  • To create an application and request access to use the SAP Ariba APIs relevant to this feature, you must have access to the SAP Ariba Developer Portal. For details refer to Steps to Start Using the SAP Ariba APIs in Help for the SAP Ariba Developer Portal.

  • All queries made to this API must be authenticated using OAuth authentication. For details refer to SAP Ariba Developer Portal Authentication in Help for the SAP Ariba Developer Portal.

  • You must know the system ID of the template to use for creating the event; you cannot use the Event Management API to search for templates.

    A template's system ID is listed in the ID field under the Overview tab of the template.

    If your site has multiple event templates configured, you can use the system IDs of the templates to get details about each template, then select a template to use for creating the event.

Context

Procedure

  1. Optional: Use the GET /events/templates endpoint to get values and definitions for specified templates. You can use the information to select a template for creating the event.

    Include the following query parameters:

    • ids=templateId : Repeat this parameter for each template that you want information for.

    • showTermsDefinitions=true: Include this parameter to include item, lot, and term definitions in the response.

    Example:

    POST {{runtime_URL}}/events/templates?user=myUser&passwordAdapter=PasswordAdapter1&realm=mySite
    &ids=SYS2222&ids=WS3333&showTermsDefinitions=true
  2. Optional: If your site has custom header fields defined for sourcing events and you want to set values for the custom fields when you create the event, use the GET /events/{eventId} endpoint to get information about an existing event.
    You can optionally specify the query filter $expand to retrieve the event information in addition to the header information. You can specify multiple values, delimited by commas.
    Valid values: all, items, supplierInvitations, teams, owners, none.
    Default: none.
    Use information from the response to add key/value pairs to the body of the POST /events/{eventId} request in the next step.

    Example:

    GET {{runtime_URL}}/events/DOC4567?user=myUser&passwordAdapter=PasswordAdapter1&realm=mySite

    The response includes information about the custom field in the specified event:

            "sourcingProjectCustomFields": [
            {
                "fieldId": "cus_MyTextField",
                "fieldName": "My Text Field",
                "fieldDataType": "textValue",
                "textValue": [
                    "Some text here"
                ],
                ...
                "customField": true
    
                      

    For additional information, refer to About Setting Custom Fields with the Event Management API

  3. Create the event using the POST /events endpoint with the system ID of the event template.
    You can include the following optional query parameters:
    • $expand: Specifies the information for the created response returned in the response in addition to header information. You can specify multiple values, delimited by commas.

      Valid values: all, items, owners, supplierInvitations, teams, none.

      Default: all.

    • inheritCommodityAndRegion: If true and the event has single values for the commodity or region (the commodities or regions array contains only one entry), any items in the request body that do not have commodity or region values specified inherit the event values for the commodity or region.

    • inheritTerms: If true, missing terms (terms for defined for items or lots in the event template but not included in the request) are automatically inherited from the event template.

      Default: false.

    • removeEmptyOwnerTerms: If true and inheritTerms is true, terms from the template that require an owner response but which do not have a response are removed from (not added to) the event item. This parameter is ignored if inheritTerms is false.

      Default: false.

    The body of the request contains a createEvent object. At a minimum, the createEvent object must contain the following elements:
    • title: The title (name) of the event.

    • templateDocumentInternalId: The internal ID of the event template.

      If the templateDocumentInternalId refers to a placeholder event within a full project, the API transitions the event to the draft state for editing, instead of creating a new event. To create a new event, specify a regular (non-placeholder) template as the templateDocumentInternalId.

    • eventTypeName: Must be RFP.

    • isTest: Specifies if this is a test project (Test Project header field).

    For information about the Test Project header field and other project header fields, refer to Sourcing project headers.

    Example:

    POST {{runtime_URL}}/events?user=myUser&passwordAdapter=PasswordAdapter1&realm=mySite

    POST /events request body with the minimum required information:

    {
      "title": "simple API event",
      "templateDocumentInternalId": "WS3333",
      "eventTypeName": "RFP",
      "isTest": "false",
    }				

    You can also specify header field values (such as currency), content (such as lots, line items or questions), and suppliers in the request body.

    The following example is a POST /events request body with:
    • Values for currency, baseLanguage, and commodities header fields, and a value for the custom header field My Text Field. The values in the request overwrite any values specified in the template.

    • 2 suppliers, specified using their assigned system IDs (sid808 and ACM_1111). No supplier contacts (users) are specified, so all contacts for the suppliers are invited.

    • A line item (My item; "itemType": 4 specifies that it is a line item). This line item is added to any content (such as question or requirement items) inherited from the template. This line item includes Price and Quantityterms. The Price term contains a value (initial value and bid value). The Price term also contains optional historicValue (historic value, used to calculate savings), and reserveValue (value which you consider the start of reasonable prices), as indicated by "historicValueProperty": 1 and "reserveValueProperty": 1.

    {
    	"title": "API event",
    	"description": "An event with 1 supplier and 1 item",
    	"templateDocumentInternalId": "WS3333",
    	"isTest": "false",
    	"eventTypeName": "RFP",
    	"currency": "USD",
    	"baseLanguage": "en",
        "commodities": [ {
                "uniqueName": "47",
                "domain": "unspsc" } ],
    	"sourcingProjectCustomFields": [
            {
                    "fieldId": "cus_MyTextField",
                    "fieldDataType": "textValue",
                    "textValue": [
                        "hello, world"
                    ],         
                    "customField": true
                }
            ],
    	"supplierInvitations": [
            {
            "organization": {
                "systemID": "sid808"
    			}     
    		}
            {
            "organization": {
                "systemID": "ACM_1111"
    			}     
    		}
    	],
    	"items": [
    		{
            "title": "My item",
            "itemType": 4,
            "terms": [ {
                "title": "Price",
                "historicValueProperty": 1,
                "reserveValueProperty": 1,
                "value": {
                    "moneyValue": {
                        "amount": 100.00,
                        "currency": "USD"
                    }
                },
                "historyValue": {
                    "moneyValue": {
                        "amount": 100.00,
                        "currency": "USD"
                    }    
                }
                "reserveValue": {
                    "moneyValue": {
                        "amount": 100.00,
                        "currency": "USD"
                    }    
                }
            },
            {
                "title": "Quantity",
                "value": {
                    "quantityValue": {
                        "amount": 2000.00,
                        "unitOfMeasureCode": "EA"
                    } } } ] } ] }					 

    When adding items, you can also specify new term definitions to add terms that aren't defined in the event template. Refer to About Defining New Terms or Formulas with the Event Management API.

  4. Optional: Evaluate the response for the POST /events request to determine if you want to modify information or contents for the event.

    The body of the response contains header field values and owners, teams, invited participants (suppliers), or content (lots, line items, or questions) specified in the POST /events request or inherited from the template.

    Retain the internalId value for the event, invitationId values for the suppliers, itemId values, and fieldId values for terms to modify these objects or get additional information about them. For example, you can use an invitationId of a supplier to get the responses submitted by that supplier.

  5. Optional: To modify header field values, contents, or suppliers for the event, use the PUT /events/{eventId} endpoint or an endpoint to add, replace, or delete specific objects, as described in Editing an Event with the Event Management API.
  6. Create a job request to publish the event. Use the POST /jobs endpoint with "resourceType": "EVENT" and "actionName": "PUBLISH" in the body.
    Example:
    POST {{runtime_URL}}/jobs?user=myUser&passwordAdapter=PasswordAdapter1&realm=mySite

    Request body:

    {
        "resourceType": "EVENT",
        "actionName": "PUBLISH",
        "ids": {
            "eventId": "Doc3500004"
        }
    }

Next Steps