# Microsoft PowerBI

## Send Vulnerability to PowerBI

{% embed url="<https://youtu.be/atT4u8HHp4s?si=pkUBRs4PCxomj40x>" %}

The purpose of this example is to send data to [PowerBI](https://app.powerbi.com) when a Vulnerability is created in AttackForge.

This example Flow can be downloaded from our [Flows GitHub Repository](https://github.com/AttackForge/Flows) and [imported](#importing-exporting-flows) into your AttackForge.

**Initial Set Up**

* **Event**: Vulnerability Created
* **Secrets**:
  * powerbi\_key - your [Push Semantic Model - Push URL](https://learn.microsoft.com/en-us/power-bi/connect-data/service-real-time-streaming)

**Action 1 - Send Vulnerability to PowerBI**

* **Method**: POST
* **URL**: \<YOUR-PUSH-URL>
* **Headers**:
  * Key = Content-Type; Type = Value; Value = application/json
* **Request Script**:

```javascript
return {
  request: {
    url: 'https://api.powerbi.com/beta/544b6efc-1149-4f8c-a17a-cad3c50cd5f8/datasets/d5ff54b4-2be2-4e02-baa2-9c6aa20a6c55/rows?experience=power-bi&key=' + secrets.powerbi_key,
    body: [
      {
        vuln_title: data.vulnerability_title,
        vuln_priority: data.vulnerability_priority
      }
    ]
  }
};
```

* **Response Script**:

```javascript
if (response?.statusCode === 200) {
  return {
    decision: 'continue'
  };
}
else {
  Logger.error(JSON.stringify(response));

  return {
    decision: { 
      status: 'abort',
      message: 'PowerBI data not posted',
    },
  };   
}
```
