cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
janne_
New Member

How to customize auto-generated file upload name field in custom connector action?

Hi,

I'm creating a custom connector with the ability to upload a file.

This is the swagger definition of the action:

 

"/action/files": {
  "post": {
    "operationId": "UploadFile",
    "summary": "Upload file",
    "consumes": [
      "multipart/form-data"
    ],
    "parameters": [
      {
        "$ref": "#/parameters/regionParam"
      },
      {
        "$ref": "#/parameters/projectIdParam"
      },
      {
        "name": "path",
        "x-ms-summary": "Folder path",
        "description": "Folder path to the file",
        "in": "query",
        "type": "string",
        "default": "/"
      },
      {
        "name": "content",
        "x-ms-summary": "File content",
        "description": "File content to upload",
        "in": "formData",
        "type": "file",
        "required": true
      }
    ],
    "responses": {
      "200": {
        "description": "OK",
        "schema": {
          "type": "object",
          "properties": {
            "fileId": {
              "type": "string",
              "x-ms-summary": "File id"
            },
            "name": {
              "type": "string",
              "x-ms-summary": "File name"
            }
          }
        }
      }
    }
  }
}

 

 This is a screenshot of what the above definition produces:

connector.png

How do I customize the description/x-ms-summary text of the automatically generated "File content (file name)" / "File content to upload (file name)" field? I would like to change it to something more user-friendly like "File name" / "File name with extension".

1 ACCEPTED SOLUTION

Accepted Solutions
janne_
New Member

That example doesn't seem to be valid. It uses { "type": "string", "format": "file" } which is not a swagger data type. But it made me take a second look at the documentation, and I noticed that an another way to upload arbitrary binary data is to use { "type": "string", "format": "binary" }, so this seems to work after also modifying the backend to read the file directly from the raw request body:

{
  "name": "filename",
  "x-ms-summary": "File name",
  "description": "File name with extension",
  "in": "query",
  "type": "string",
  "required": true
},
{
  "name": "content",
  "x-ms-summary": "File content",
  "description": "File content to upload",
  "in": "body",
  "schema": {
    "type": "string",
    "format": "binary"
  },
  "required": true
}

 

View solution in original post

2 REPLIES 2
murshed
Microsoft
Microsoft

Hi @janne_ 

Here is an example of how to do it: https://powerusers.microsoft.com/t5/Building-Flows/Custom-connector-with-action-that-uses-formdata-t...

Basically you create three fields with formdata. Please let me know if this works.

 

If this reply answers your question or solves your issue, please ACCEPT AS SOLUTION ☑️. If you find this reply helpful, please consider giving it a LIKE 👍.

janne_
New Member

That example doesn't seem to be valid. It uses { "type": "string", "format": "file" } which is not a swagger data type. But it made me take a second look at the documentation, and I noticed that an another way to upload arbitrary binary data is to use { "type": "string", "format": "binary" }, so this seems to work after also modifying the backend to read the file directly from the raw request body:

{
  "name": "filename",
  "x-ms-summary": "File name",
  "description": "File name with extension",
  "in": "query",
  "type": "string",
  "required": true
},
{
  "name": "content",
  "x-ms-summary": "File content",
  "description": "File content to upload",
  "in": "body",
  "schema": {
    "type": "string",
    "format": "binary"
  },
  "required": true
}

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,686)