<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: March Developer Challenge - CloudEvents: Week 2 in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13640761#M2027201</link>
    <description>&lt;P&gt;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/129270"&gt;@MarcelloUrbani&lt;/a&gt;I've seen those format errors before.... You can include the formats by adding them to &lt;FONT face="courier new,courier"&gt;ajv&lt;/FONT&gt;. You will also need to &lt;FONT face="courier new,courier"&gt;npm install ajv-formats&lt;/FONT&gt;. See &lt;A href="https://www.npmjs.com/package/ajv-formats" target="_self"&gt;ajv-formats&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const Ajv = require('ajv');
const addFormats = require("ajv-formats");

const ajv = new Ajv();
addFormats(ajv);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 17 Mar 2024 21:00:44 GMT</pubDate>
    <dc:creator>ajmaradiaga</dc:creator>
    <dc:date>2024-03-17T21:00:44Z</dc:date>
    <item>
      <title>March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13635719#M2027094</link>
      <description>&lt;P class=""&gt;As we learned last week, CloudEvents is a specification for describing event data in common formats and the goal is to provide interoperability across services, platforms and systems. This week we will expand on what we learnt last week and we will create our first CloudEvent programmatically.&lt;/P&gt;&lt;BLOCKQUOTE dir="auto"&gt;&lt;P&gt;Links to March's developer challenge:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Week 1: &lt;A href="https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-1/td-p/13629129" target="_blank" rel="noopener"&gt;https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-1/td-p/13629129&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Week 2: &lt;A href="https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-2/m-p/13635719" target="_blank" rel="noopener"&gt;https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-2/m-p/13635719&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Week 3: &lt;A href="https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-3/td-p/13642145" target="_blank" rel="noopener"&gt;https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-3/td-p/13642145&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Week 4: &lt;A href="https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-4/td-p/13648232" target="_blank" rel="noopener"&gt;https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-4/td-p/13648232&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;/BLOCKQUOTE&gt;&lt;H2&gt;CloudEvent format&lt;/H2&gt;&lt;P class=""&gt;Event Formats specify how to serialize a CloudEvent with certain encoding formats. Depending on our requirements it is possible that we might need to use a specific format to encode our CloudEvent message. Maybe we have a requirement where we need to send the data in something different than the JSON format, e.g.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A title="https://github.com/cloudevents/spec/blob/main/cloudevents/formats/avro-format.md" href="https://github.com/cloudevents/spec/blob/main/cloudevents/formats/avro-format.md" target="_blank" rel="noopener"&gt;AVRO&lt;/A&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A title="https://github.com/cloudevents/spec/blob/main/cloudevents/formats/protobuf-format.md" href="https://github.com/cloudevents/spec/blob/main/cloudevents/formats/protobuf-format.md" target="_blank" rel="noopener"&gt;Protobuf&lt;/A&gt;. Check out the specification document if you want to learn more about these&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A title="https://github.com/cloudevents/spec/blob/main/cloudevents/formats/" href="https://github.com/cloudevents/spec/blob/main/cloudevents/formats/" target="_blank" rel="noopener"&gt;different formats&lt;/A&gt;.&lt;/P&gt;&lt;BLOCKQUOTE dir="auto"&gt;&lt;P class=""&gt;For simplicity purposes we will stick to the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A title="https://github.com/cloudevents/spec/blob/main/cloudevents/formats/json-format.md" href="https://github.com/cloudevents/spec/blob/main/cloudevents/formats/json-format.md" target="_blank" rel="noopener"&gt;JSON Event format&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;as it is the most common and easiest to interact with.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P class=""&gt;Now that we are familiar with what a CloudEvent is, what a CloudEvent message looks like, and the different Event Formats available, let's see how we can create one programmatically.&lt;/P&gt;&lt;H2&gt;CloudEvents SDK&lt;/H2&gt;&lt;P class=""&gt;There are language-specific SDKs that can be used to create a message that complies with the CloudEvents standard. Below is a list of the different languages that there's an SDK for:&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;A title="https://github.com/cloudevents/sdk-csharp" href="https://github.com/cloudevents/sdk-csharp" target="_blank" rel="noopener"&gt;C#&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A title="https://github.com/cloudevents/sdk-go" href="https://github.com/cloudevents/sdk-go" target="_blank" rel="noopener"&gt;Go&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A title="https://github.com/cloudevents/sdk-java" href="https://github.com/cloudevents/sdk-java" target="_blank" rel="noopener"&gt;Java&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A title="https://github.com/cloudevents/sdk-javascript" href="https://github.com/cloudevents/sdk-javascript" target="_blank" rel="noopener"&gt;Javascript&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A title="https://github.com/cloudevents/sdk-php" href="https://github.com/cloudevents/sdk-php" target="_blank" rel="noopener"&gt;PHP&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A title="https://github.com/cloudevents/sdk-powershell" href="https://github.com/cloudevents/sdk-powershell" target="_blank" rel="noopener"&gt;PowerShell&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A title="https://github.com/cloudevents/sdk-python" href="https://github.com/cloudevents/sdk-python" target="_blank" rel="noopener"&gt;Python&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A title="https://github.com/cloudevents/sdk-ruby" href="https://github.com/cloudevents/sdk-ruby" target="_blank" rel="noopener"&gt;Ruby&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;A title="https://github.com/cloudevents/sdk-rust" href="https://github.com/cloudevents/sdk-rust" target="_blank" rel="noopener"&gt;Rust&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P class=""&gt;You might be thinking, why would I need an SDK when I can create the message "manually" as well? Using an SDK allows us to easily create a CloudEvent message, ensure that it follows the guidelines defined in the standard, and simplify generating the output format. Not only that but it can also be used to parse a CloudEvent message that our application consumes. As an example, I will use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A title="https://github.com/cloudevents/sdk-python" href="https://github.com/cloudevents/sdk-python" target="_blank" rel="noopener"&gt;Python SDK&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to create the CloudEvent message for the Ticket Management System that I used as an example previously.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from cloudevents.http import CloudEvent
from cloudevents.conversion import to_binary
import requests

ticket_id = "IT00010232"

# Create a CloudEvent
attributes = {
    "type": "com.ajmaradiaga.tms.Ticket.Created.v1",
    "source": "https://tms-prod.ajmaradiaga.com/tickets",
    "subject": ticket_id,
}
data = { 
    "ID": ticket_id,
    "Description": "Install ColdTurkey to block distracting websites.",
    "Urgency": {
      "ID": 1,
      "Description": "High"
    }
  }
event = CloudEvent(attributes, data)

# Creates the HTTP request representation of the CloudEvent in binary content mode
headers, body = to_binary(event)

print(body)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H2&gt;Week 2 challenge - Create a CloudEvent using an SDK&lt;/H2&gt;&lt;P class=""&gt;&lt;span class="lia-unicode-emoji" title=":backhand_index_pointing_right:"&gt;👉&lt;/span&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;Your task for this week is&lt;/STRONG&gt;: Pick your favourite language from the list above and create the message that you shared as part of week's 1 challenge but this time instead of doing it manually, you will do it using an SDK. &lt;STRONG&gt;To complete this week's challenge, share the code you used to create the CloudEvent message and a screenshot of your program's output.&lt;/STRONG&gt;&lt;/P&gt;&lt;BLOCKQUOTE dir="auto"&gt;&lt;P class=""&gt;What if there is no SDK available for your favourite language? Not a problem, you can create the message structure "manually". Just share the code used to generate a message in your programming language and a screenshot of the program's output.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 22 May 2025 06:35:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13635719#M2027094</guid>
      <dc:creator>ajmaradiaga</dc:creator>
      <dc:date>2025-05-22T06:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13635721#M2027095</link>
      <description>&lt;P class=""&gt;Using as a reference my solution for week 1, I will use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A title="https://github.com/cloudevents/sdk-python" href="https://github.com/cloudevents/sdk-python" target="_blank" rel="noopener"&gt;CloudEvents Python SDK&lt;/A&gt;.&lt;/P&gt;&lt;H4&gt;Code&lt;/H4&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import json

from cloudevents.conversion import to_structured
from cloudevents.http import CloudEvent
import requests

# Create a CloudEvent
# - The CloudEvent "id" is generated if omitted. "specversion" defaults to "1.0".
attributes = {
    "type": "com.ajmaradiaga.tms.Ticket.Created.v1",
    "source": "https://tms-prod.ajmaradiaga.com/tickets",
}
data = {
    "id": "IT00010232",
    "description": "Install ColdTurkey to block distracting websites.",
    "urgency": {
        "id": 1,
        "description": "High"
    }
}
event = CloudEvent(attributes, data)

# Creates the HTTP request representation of the CloudEvent in structured content mode
headers, body = to_structured(event)

print(headers)

json_body = json.loads(body)

# Pretty print json
print(json.dumps(json_body, indent=2))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H4&gt;Screenshot of the program running&lt;/H4&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Week 2 solution" style="width: 999px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/77717i7771E5F40543E70D/image-size/large?v=v2&amp;amp;px=999" role="button" title="week-2-solution.png" alt="Week 2 solution" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Week 2 solution&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2024 14:35:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13635721#M2027095</guid>
      <dc:creator>ajmaradiaga</dc:creator>
      <dc:date>2024-03-12T14:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13635822#M2027097</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Here is my submission&lt;/SPAN&gt; &lt;span class="lia-unicode-emoji" title=":vulcan_salute:"&gt;🖖&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code JS:&lt;/STRONG&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const { CloudEvent, HTTP } = require("cloudevents");

const ce = new CloudEvent({
    specversion: "1.0",
    type: "com.example.iot.device.event.v1",
    source: "https://iot-prod.example.com/devices",
    subject: "device12345-temperature-alert",
    id: "e241f360-4b3f-4c9b-a5e4-d35456b27f62",
    time: "2024-03-06 08:34:00",
    datacontenttype: "application/json",
    data: {
        device_id: "Device12345",
        event_type: "temperature-alert",
        description: "Temperature threshold exceeded.",
        data: {
            temperature: 75,
            threshold: 70,
            units: "Celsius",
        },
    },
});

const { headers, body } = HTTP.structured(ce);

console.log("Headers:");
console.log(JSON.stringify(headers, null, 2) + "\n");

console.log("Body:");
console.log(JSON.stringify(JSON.parse(body), null, 2) + "\n");&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;Result:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="r00k13d3v_0-1710256792872.png" style="width: 999px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/79414i89E339386B69EA7F/image-size/large?v=v2&amp;amp;px=999" role="button" title="r00k13d3v_0-1710256792872.png" alt="r00k13d3v_0-1710256792872.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2024 15:25:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13635822#M2027097</guid>
      <dc:creator>r00k13d3v</dc:creator>
      <dc:date>2024-03-12T15:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13635931#M2027098</link>
      <description>&lt;P&gt;My reference for week 1:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-1/td-p/13629129#:~:text=%7B%0A%22specversion%22%3A%20%221.0%22%2C%0A%22id%22%3A%20%2262706ed3%2D3f4c%2D4a48%2Da2e7%2D8f201301822b%22%2C%0A%22type%22%3A%20%22.com.alpesadevcha.v1%22%2C%0A%22source%22%3A%20%22/alpesadev/test%22%2C%0A%22time%22%3A%20%222024%2D03%2D07T08%3A00%3A00Z%22%2C%0A%22datacontenttype%22%3A%20%22application/json%22%2C%0A%22data%22%3A%20%7B%0A%09%22employee%22%3A%20%2280001000%22%0A%09%7D%0A%7D" target="_blank"&gt;https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-1/td-p/13629129#:~:text=%7B%0A%22specversion%22%3A%20%221.0%22%2C%0A%22id%22%3A%20%2262706ed3%2D3f4c%2D4a48%2Da2e7%2D8f201301822b%22%2C%0A%22type%22%3A%20%22.com.alpesadevcha.v1%22%2C%0A%22source%22%3A%20%22/alpesadev/test%22%2C%0A%22time%22%3A%20%222024%2D03%2D07T08%3A00%3A00Z%22%2C%0A%22datacontenttype%22%3A%20%22application/json%22%2C%0A%22data%22%3A%20%7B%0A%09%22employee%22%3A%20%2280001000%22%0A%09%7D%0A%7D&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My JS code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const { CloudEvent, HTTP} = require("cloudevents");

// Create a new CloudEvent
const ce = new CloudEvent({ 
  "specversion": "1.0",
  "id": "62706ed3-3f4c-4a48-a2e7-8f201301822b",
  "type": ".com.alpesadevcha.v1",
  "source": "/alpesadev/test",
  "time": "2024-03-07T08:00:00Z",
  "datacontenttype": "application/json",
  "data": {
    "employee": "80001000"
    }
}); 

//
const { headers, body } = HTTP.structured(ce);

console.log(
   "Headers:", "\n",
    JSON.stringify(headers, null, 2), "\n",
    "Body:", "\n",
    JSON.stringify(JSON.parse(body), null, 2));&lt;/LI-CODE&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Headers: 
 {
  "content-type": "application/cloudevents+json; charset=utf-8"
}
 Body:
 {
  "id": "62706ed3-3f4c-4a48-a2e7-8f201301822b",
  "time": "2024-03-07T08:00:00.000Z",
  "type": ".com.alpesadevcha.v1",
  "source": "/alpesadev/test",
  "specversion": "1.0",
  "datacontenttype": "application/json",
  "data": {
    "employee": "80001000"
  }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 12 Mar 2024 17:05:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13635931#M2027098</guid>
      <dc:creator>Alpesa1990</dc:creator>
      <dc:date>2024-03-12T17:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13636042#M2027100</link>
      <description>&lt;P&gt;My previous solution &lt;A href="https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-1/td-p/13629129#:~:text=%7B%0A%20%20%20%20%22type%22%3A%20%22sap.s4.beh.maintenanceorder,%2C%0A%20%20%20%20%20%20%20%20%22MaintenanceOrderType%22%3A%22YA01%22%0A%20%20%20%20%7D%0A%7D" target="_self"&gt;Week 1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emiliocampo_0-1710267937855.png" style="width: 400px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/79509iFC0AA5B998763932/image-size/medium?v=v2&amp;amp;px=400" role="button" title="emiliocampo_0-1710267937855.png" alt="emiliocampo_0-1710267937855.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Screenshot&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emiliocampo_1-1710268001074.png" style="width: 400px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/79513iF75663C2A757AC22/image-size/medium?v=v2&amp;amp;px=400" role="button" title="emiliocampo_1-1710268001074.png" alt="emiliocampo_1-1710268001074.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2024 18:30:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13636042#M2027100</guid>
      <dc:creator>emiliocampo</dc:creator>
      <dc:date>2024-03-12T18:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13636183#M2027105</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Code PWS:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="bash"&gt;$cloudEvent = New-CloudEvent `
    -Type 'com.example.iot.device.event.v1' `
    -Source 'https://iot-prod.example.com/devices' `
    -Id 'e241f360-4b3f-4c9b-a5e4-d35456b27f62' `
    -Time '2024-03-06 08:34:00' `

$cloudEvent | Set-CloudEventJsonData -Data @{
    specversion = "1.0"
    type = "com.example.iot.device.event.v1"
    source = "https://iot-prod.example.com/devices"
    subject = "device12345-temperature-alert"
    id = "e241f360-4b3f-4c9b-a5e4-d35456b27f62"
    time = "2024-03-06 08:34:00"
    datacontenttype = "application/json"
    data = @{
        device_id = "Device12345"
        event_type = "temperature-alert"
        description = "Temperature threshold exceeded."
        data = @{
            temperature = 75
            threshold = 70
            units = "Celsius"
        }
    }
} &amp;gt; $null

$cloudEventStructuredHttpMessage = $cloudEvent | ConvertTo-HttpMessage -ContentMode Structured

Write-Host
Write-Host "Headers:" -ForegroundColor Green
$cloudEventStructuredHttpMessage.Headers

Write-Host
Write-Host "Body:" -ForegroundColor Green
Read-CloudEventData -CloudEvent $cloudEvent&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;Result:&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="r00k13d3v_1-1710275852344.png" style="width: 400px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/79625i6928591452792E77/image-size/medium?v=v2&amp;amp;px=400" role="button" title="r00k13d3v_1-1710275852344.png" alt="r00k13d3v_1-1710275852344.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Mar 2024 20:37:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13636183#M2027105</guid>
      <dc:creator>r00k13d3v</dc:creator>
      <dc:date>2024-03-12T20:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13636408#M2027108</link>
      <description>&lt;P&gt;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/38628"&gt;@r00k13d3v&lt;/a&gt;&amp;nbsp;Absolutely love this.... it never crossed my mind that someone would share something using the Powershell SDK... AMAZING!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 05:42:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13636408#M2027108</guid>
      <dc:creator>ajmaradiaga</dc:creator>
      <dc:date>2024-03-13T05:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13636410#M2027109</link>
      <description>&lt;P&gt;&lt;a href="https://community.sap.com/t5/user/viewprofilepage/user-id/43545"&gt;@emiliocampo&lt;/a&gt;&amp;nbsp;Thanks for sharing the &lt;EM&gt;to_binary&lt;/EM&gt; representation, so others can see what the difference is when outputting &lt;EM&gt;to_structured&lt;/EM&gt; and &lt;EM&gt;to_binary. &lt;/EM&gt;Great example!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 05:55:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13636410#M2027109</guid>
      <dc:creator>ajmaradiaga</dc:creator>
      <dc:date>2024-03-13T05:55:28Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13636753#M2027112</link>
      <description>&lt;P&gt;&lt;EM&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-03-13 at 5.05.46 PM.png" style="width: 999px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/79880i879B8F76112DC71C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-03-13 at 5.05.46 PM.png" alt="Screenshot 2024-03-13 at 5.05.46 PM.png" /&gt;&lt;/span&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from cloudevents.conversion import to_structured
from cloudevents.http import CloudEvent
import json

attributes = {
    "type": "com.servicechannel.WorkOrder.Created.v1",
    "source": "https://test.servicechannel.com/workorders",
}
data = {
        "purchaseNumber": "84409626",
        "status": {
            "primary": "open"
        }
    }
event = CloudEvent(attributes, data)

headers, body = to_structured(event)
print(f"Content-Type: {headers['content-type']}\n")
json_body = json.loads(body)
print(f"Sample Cloud Event: \n{json.dumps(json_body, indent=2)}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 11:37:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13636753#M2027112</guid>
      <dc:creator>PriyankaChak</dc:creator>
      <dc:date>2024-03-13T11:37:41Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13637185#M2027122</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//Importing Cloud Event libraries.

const { CloudEvent, HTTP } = require("cloudevents");

const type = "com.awesome_company.sales_order.Updated.v1"
const source = "https://prod.illidian.awesome_company.com/sales_orders" 
const salesOrderID = "9024000013"
const company = "AWO01"
const year = 2024
const statusSO = "Shipped"

const subject = company + salesOrderID + year

const data = {
    "salesOrder": salesOrderID,
    "company": company,
    "year": year,
    "status": statusSO
}

//creating and calling event

const soEvent = new CloudEvent({type,source,subject,data})

const { headers, body } = HTTP.structured(soEvent);

//print the log

console.log("### March Developer Challenge - CloudEvents: Week 2 ###\n");
console.log("- HTTP Event Headers - \n")
for (const key in headers) {
    console.log(`Key: "${key}", Value: "${headers[key]}"`);
  }

console.log("\n - HTTP Event Body - \n");
console.log(JSON.stringify(JSON.parse(body), null, 1) + "\n");&lt;/LI-CODE&gt;&lt;P&gt;JS!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xavisanse_1-1710345603047.png" style="width: 999px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/80123i2DE6BB4C30359FB5/image-size/large?v=v2&amp;amp;px=999" role="button" title="xavisanse_1-1710345603047.png" alt="xavisanse_1-1710345603047.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 16:02:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13637185#M2027122</guid>
      <dc:creator>xavisanse</dc:creator>
      <dc:date>2024-03-13T16:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13637234#M2027123</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dan_Wroblewski_0-1710347944337.png" style="width: 822px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/80141i3CD7B68D904D8B9A/image-dimensions/822x674?v=v2" width="822" height="674" role="button" title="Dan_Wroblewski_0-1710347944337.png" alt="Dan_Wroblewski_0-1710347944337.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Dan_Wroblewski_1-1710348024650.png" style="width: 827px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/80142i11C91892D741CA1F/image-dimensions/827x436?v=v2" width="827" height="436" role="button" title="Dan_Wroblewski_1-1710348024650.png" alt="Dan_Wroblewski_1-1710348024650.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 16:41:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13637234#M2027123</guid>
      <dc:creator>Dan_Wroblewski</dc:creator>
      <dc:date>2024-03-13T16:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13637390#M2027126</link>
      <description>&lt;P&gt;I don't want to lie... I tried because it's something that blows my mind, &lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 20:29:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13637390#M2027126</guid>
      <dc:creator>r00k13d3v</dc:creator>
      <dc:date>2024-03-13T20:29:16Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13637429#M2027127</link>
      <description>&lt;P&gt;Why not creating the CloudEvent in Groovy if we want to use Integration Suite for that?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import com.sap.gateway.ip.core.customdev.util.Message
import java.util.HashMap
import java.text.SimpleDateFormat

def Message processData(Message message) {

    //read properties
        def properties = message.getProperties()
        specversion = properties.get("specversion")
        type = properties.get("type")
        source = properties.get("source")
        id = properties.get("id")

    //create timestamp
        def date = new Date()
        def sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")

    //read data from body

        def data = message.getBody(String)

    //create CloudEvent

        message.setBody("{\r\n\"specversion\": \"" + specversion +"\",\r\n\"type\": \""+ type +"\",\r\n\"source\": \""+ source +"\",\r\n\"id\": \""+ id +"\",\r\n\"time\": \""+ sdf.format(date) +"\",\r\n\"datacontenttype\": \"application/json\",\r\n\"data\":" + data + "}")
    return message
    
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="fjaviergar07_0-1710365990244.png" style="width: 999px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/80236iA75B96D67E3D41FC/image-size/large?v=v2&amp;amp;px=999" role="button" title="fjaviergar07_0-1710365990244.png" alt="fjaviergar07_0-1710365990244.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 21:40:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13637429#M2027127</guid>
      <dc:creator>fjaviergar07</dc:creator>
      <dc:date>2024-03-13T21:40:17Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13637984#M2027135</link>
      <description>&lt;LI-CODE lang="python"&gt;import json

from cloudevents.conversion import to_json
from cloudevents.http import CloudEvent

attributes = {
    "type": "sap.s4.beh.productionorder.v1.ProductionOrder.Created.v1",
    "source": "https://m32z.ucc.ovgu.de/",
}

data = {
    "ProductionOrder": "1000206",
    "ProductionOrderType": "PP01",
    "ProductionPlant": "HD00",
}

event = CloudEvent(attributes, data)
print(json.dumps(json.loads(to_json(event)), indent=2))&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CleanShot 2024-03-14 at 10.27.47.png" style="width: 707px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/80548i79FA0979736205A4/image-size/large?v=v2&amp;amp;px=999" role="button" title="CleanShot 2024-03-14 at 10.27.47.png" alt="CleanShot 2024-03-14 at 10.27.47.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 09:30:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13637984#M2027135</guid>
      <dc:creator>ceedee666</dc:creator>
      <dc:date>2024-03-14T09:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13638027#M2027136</link>
      <description>&lt;P&gt;Hello ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my &lt;A href="https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-1/m-p/13633868/highlight/true#M2027062" target="_self"&gt;Week1&lt;/A&gt; response.&lt;/P&gt;&lt;P&gt;Below is my JS code to populate the same Cloud Event :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; { &lt;/SPAN&gt;&lt;SPAN&gt;CloudEvent&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;HTTP&lt;/SPAN&gt;&lt;SPAN&gt; } &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;require&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"cloudevents"&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPA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lt;DIV&gt;&lt;SPAN&gt;console&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;log&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;JSON&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;stringify&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;JSON&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;parse&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;body&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;null&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;+&lt;/SPAN&gt; &lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;\n&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Here is the output :&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pamoli_banerjee_0-1710409541010.png" style="width: 400px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/80580iD5C5CB54A1F8F695/image-size/medium?v=v2&amp;amp;px=400" role="button" title="pamoli_banerjee_0-1710409541010.png" alt="pamoli_banerjee_0-1710409541010.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 14 Mar 2024 09:46:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13638027#M2027136</guid>
      <dc:creator>pamoli_banerjee</dc:creator>
      <dc:date>2024-03-14T09:46:35Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13638089#M2027137</link>
      <description>&lt;P&gt;Here is my submission&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const { CloudEvent, HTTP } = require("cloudevents");

const ce = new CloudEvent({
    specversion: "1.0",
    type: "sap.s4.beh.centralrequestforquotation.v1.CentralRequestForQuotation.SuccssrDocCrted.v1",
    source: "/default/sap.s4.beh/s4hc",
    id: "QgEK7wzuHtqdeJwqCS+VOA==",
    time: "2024-03-11T13:00:00Z",
    datacontenttype: "application/json",
    data: {
        CentralRequestForQuotation: "7500000012"
    },
});

const { headers, body } = HTTP.structured(ce);

console.log("Headers:");
console.log(JSON.stringify(headers, null, 2) + "\n");

console.log("Body:");
console.log(JSON.stringify(JSON.parse(body), null, 2) + "\n");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="json"&gt;Headers:
{
  "content-type": "application/cloudevents+json; charset=utf-8"
}

Body:
{
  "id": "QgEK7wzuHtqdeJwqCS+VOA==",
  "time": "2024-03-11T13:00:00.000Z",
  "type": "sap.s4.beh.centralrequestforquotation.v1.CentralRequestForQuotation.SuccssrDocCrted.v1",
  "source": "/default/sap.s4.beh/s4hc",
  "specversion": "1.0",
  "datacontenttype": "application/json",
  "data": {
    "CentralRequestForQuotation": "7500000012"
  }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 14 Mar 2024 10:04:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13638089#M2027137</guid>
      <dc:creator>SyambabuAllu</dc:creator>
      <dc:date>2024-03-14T10:04:15Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13638227#M2027139</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ajos_0-1710417332583.png" style="width: 400px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/80686i5691530D6237BDE1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ajos_0-1710417332583.png" alt="ajos_0-1710417332583.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ajos_1-1710417383141.png" style="width: 400px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/80687i117D4081B683C5D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ajos_1-1710417383141.png" alt="ajos_1-1710417383141.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 11:56:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13638227#M2027139</guid>
      <dc:creator>ajos</dc:creator>
      <dc:date>2024-03-14T11:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13638434#M2027143</link>
      <description>&lt;P&gt;This is the reference for my week 1 proposal:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ruthiel_0-1710425710926.png" style="width: 744px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/80775i9A3A19A47FDE9CCB/image-dimensions/744x1225?v=v2" width="744" height="1225" role="button" title="Ruthiel_0-1710425710926.png" alt="Ruthiel_0-1710425710926.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 14:15:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13638434#M2027143</guid>
      <dc:creator>Ruthiel</dc:creator>
      <dc:date>2024-03-14T14:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13639153#M2027158</link>
      <description>&lt;P&gt;Here is my submission for Week 2:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="amitcruz_0-1710479186891.png" style="width: 400px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/81162i06154F30AF19B967/image-size/medium?v=v2&amp;amp;px=400" role="button" title="amitcruz_0-1710479186891.png" alt="amitcruz_0-1710479186891.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 05:06:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13639153#M2027158</guid>
      <dc:creator>amitcruz</dc:creator>
      <dc:date>2024-03-15T05:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: March Developer Challenge - CloudEvents: Week 2</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13639627#M2027179</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;My solution for week 1:&amp;nbsp;&lt;A href="https://community.sap.com/t5/application-development-discussions/march-developer-challenge-cloudevents-week-1/m-p/13632055/highlight/true#M2027024" target="_self"&gt;week-1-solution&lt;/A&gt;&amp;nbsp;, I will use python sdk&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import json

from cloudevents.conversion import to_structured
from cloudevents.http import CloudEvent


# Create a CloudEvent
# - The CloudEvent "id" is generated if omitted. "specversion" defaults to "1.0".
attributes = {
    "type": "sap.s4.beh.product.v1.Product.Changed.v1",
    "source": "../dictionary",
    "subject": "productId:123",
}
data = {
    "Product": "123",
    "ProductCategory": "TELE",
    "ProductType": "LCD"
}
event = CloudEvent(attributes, data)

# Creates the HTTP request representation of the CloudEvent in structured content mode
headers, body = to_structured(event)

print("headers:")
print(headers)
print()


json_body = json.loads(body)

# Pretty print json
print("body:")
print(json.dumps(json_body, indent=2))&lt;/LI-CODE&gt;&lt;P&gt;Screenshot of the output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="tobiasz_h_0-1710501791501.png" style="width: 400px;"&gt;&lt;img src="https://community.sap.com/t5/image/serverpage/image-id/81383i4CE28629AB4AD4BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="tobiasz_h_0-1710501791501.png" alt="tobiasz_h_0-1710501791501.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 11:25:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/march-developer-challenge-cloudevents-week-2/m-p/13639627#M2027179</guid>
      <dc:creator>tobiasz_h</dc:creator>
      <dc:date>2024-03-15T11:25:37Z</dc:date>
    </item>
  </channel>
</rss>

