Power Automate: References - NovaGL/coupa-resources GitHub Wiki
There may be times when building your actions that you are finding you are repeating properties.
This is where references come in. An example of this is adding an attachment.
You could add the attachment in multiple areas for example a Purchase order header or a Purchase Order comment.
Add Attachment (URL) to a Purchase Order
The following explains how to add a URL to the OrderHeader
Scopes: core.purchase_order.read core.purchase_order.write core.attachment.read core.attachment.write
General
Title | Value |
---|---|
Summary | Attachments - Add Attachment (URL) to a Purchase Order |
Description | Add Attachment (URL) to a Purchase Order |
Operation ID | Attachments_PO |
Request
Import from Sample
Title | Value |
---|---|
Verb | POST |
URL | /api/purchase_orders/{id}/attachments/ |
Headers | Accept application/json (don’t forget to default the value) |
Body
{
"viewable": "string", (edit dropdown to be "Internal", "Supplier")
"url": "string"
}
Response
Click import from sample and paste the following
{
"id": "000",
"created-at": "2022-01-01",
"updated-at": "2022-01-01",
"type": "AttachmentUrl",
"intent": "Internal",
"url": "www.google.com"
}
Add Attachment (URL) to a comment
The following explains how to add a URL to a comment
Scopes: core.purchase_order.read core.purchase_order.write core.attachment.read core.attachment.write core.comment.read core.comment.write
General
Title | Value |
---|---|
Summary | Attachments - Add Attachment (URL) to a Comment |
Description | Add Attachment (URL) to a Comment |
Operation ID | Attachments_Comment |
Request
Import from Sample
Title | Value |
---|---|
Verb | POST |
URL | /api/comments/{id}/attachments/ |
Headers | Accept application/json (don’t forget to default the value) |
Body
{
"intent": "string", (edit dropdown to be "Internal", "Supplier")
"url": "string"
}
Response Rather than fill the same response in again we are going to add it as a reference in the Swagger editor.
Swagger Editor Definitions
Click the toggle on the Swagger Editor.
Scroll down to where it says definitions and remove the {} and press enter and add the following:
Attachments:
type: object
properties:
id:
type: integer
format: int32
description: id
created-at:
type: string
description: created-at
updated-at:
type: string
description: updated-at
type:
type: string
description: type
intent:
type: string
description: intent
url:
type: string
description: url
Adding references to Actions
Scroll back up to to operationId: Attachments_Comment
and find the line that says schema: {}
Remove the {} and press enter add the following line making sure the indentation is correct
$ref: '#/definitions/Attachments
Do the same for operationId: Attachments_PO
by removing the response object and replacing it with a reference.
Now whenever you want to update the response object for attachments you just need to do it in one place.