cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SaWu
Impactful Individual
Impactful Individual

Custom connector expecting application/xhtml+xml, getting text/plain via flow

I am trying to connect to an API (Microsoft Graph connection to OneNote with app registration via Azure, appropriate rights etc) that (for my use case) expects one xhtml file (Presentation part, the page posted to onenote)
    application/xhtml+xml
and a picture (card part, a picture for extract.businesscard) as part of a
   multipart/form-data
POST request.
I already built a custom connector with a swagger (OpenAPI 2) file but cannot successfully feed the xhtml/Presentation part.
I need to do it this way because extract.businesscard only seems to work for these multipart requests.
Sending just the html with the image embedded as base64 image does not generate the extracted business card section with embedded vcf.

My flow (simplified and abridged) consists of a
    http-Request
trigger followed by my custom connector which gets passed, expecting first the picture, then the xhtml
    card: triggerMultipartBody(0)
    Presentation: triggerMultipartBody(1)
2018-07-27 10_14_28-Edit your flow _ Microsoft Flow.png
I don't know what

card (file name), Presentation (file name)
are supposed to do.

Testing the flow with postman (posting to the http-Request trigger url), the flow basically works, but the Content-Type of the xhtml/Presentation part of the multipart/form-data request seems to get messed up.
2018-07-27 10_13_50-Postman.png2018-07-27 10_15_12-Run History _ Microsoft Flow.png

Directly using postman to test the API that the custom connector is built for works.
2018-07-27 10_29_59-Postman.png
I also tried using an exported Postman v1 of this Postman request.
This generates a connector with a strange key/value-something (json?) trigger() that I can't feed at all from flow.

  1. Is my problem because of my custom connector/swagger (swagger file at end of this post)?
    As far as I've read (and tested), OpenAPI 3 allows Content-Type declarations for multipart-formdata requests, but OpenAPI 3 is not supported by Custom Connectors.
    Is there a microsoft vendor extension for the swagger/OpenAPI 2 to enforce Content-Type for multipart-formdata?
  2. Or do I need to change the flow?
  3. Or do something with "file name"?

PS: my swagger file for the custom connector, the /me get action is just for authentification testing purposes.
The /me/onenote/pages post action causes my issues.

{
  "info": {
    "title": "Graph OneNote",
    "description": "Access OneNote via Graph API",
    "version": "1.0.1"
  },
  "paths": {
    "/v1.0/me": {
      "get": {
        "summary": "Get me",
        "operationId": "GetMe",
        "responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "object",
              "properties": {
                "@odata.context": {
                  "type": "string"
                },
                "id": {
                  "type": "string"
                },
                "businessPhones": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "displayName": {
                  "type": "string"
                },
                "givenName": {
                  "type": "string"
                },
                "jobTitle": {
                  "type": "string"
                },
                "mail": {
                  "type": "string"
                },
                "mobilePhone": {
                  "type": "string"
                },
                "officeLocation": {
                  "type": "string"
                },
                "preferredLanguage": {
                  "type": "string"
                },
                "surname": {
                  "type": "string"
                },
                "userPrincipalName": {
                  "type": "string"
                }
              }
            }
          }
        },
        "parameters": []
      }
    },
    "/v1.0/me/onenote/pages": {
      "post": {
        "summary": "Create new OneNote Page with picture",
        "operationId": "PostPage",
        "consumes": [
          "multipart/form-data"
        ],
        "responses": {
          "201": {
            "description": "Created new page with uploaded picture",
            "schema": {
              "type": "object",
              "properties": {
                "@odata.context": {
                  "type": "string"
                },
                "id": {
                  "type": "string"
                },
                "self": {
                  "type": "string"
                },
                "createdDateTime": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "createdByAppId": {
                  "type": "string"
                },
                "contentUrl": {
                  "type": "string"
                },
                "lastModifiedDateTime": {
                  "type": "string"
                },
                "links": {
                  "type": "object",
                  "properties": {                   
                    "oneNoteClientUrl": {
                      "type": "string"
                    },
                    "oneNoteWebUrl": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "in": "formData",
            "name": "card",
            "type": "file",
            "description": "a picture",
            "required": true,
            "x-ms-media-kind": "image"
          },
          {
            "in": "formData",
            "name": "Presentation",
            "type": "file",
            "required": true
          }
        ]
      }
    }
  },
  "security": [
    {
      "OAuth2": []
    }
  ],
  "swagger": "2.0",
  "schemes": [
    "https"
  ],
  "host": "graph.microsoft.com",
  "basePath": "/",
  "securityDefinitions": {
    "OAuth2": {
      "type": "oauth2",
      "flow": "accessCode",
      "authorizationUrl": "https://login.windows.net/common/oauth2/authorize?resource=https://graph.microsoft.com",
      "tokenUrl": "https://login.microsoftonline.com/common/oauth2/token",
      "scopes": {}
    }
  },
  "x-components": {}
}

 

3 REPLIES 3
v-yamao-msft
Community Support
Community Support

Hi @SaWu,

 

The error message says that the Presentation part content type should be text/html or application/xhtml+xml while you are using text/plain.

 

Please check the content type you are using and make sure it is text/html or application/xhtml+xml.

 

More details about custom connectors, please check the following docs:

Custom connectors in Microsoft Flow

Create your custom integrations in Microsoft Flow using our new and improved Custom API experience

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
SaWu
Impactful Individual
Impactful Individual

As I've already written:
"Testing the flow with postman (posting to the http-Request trigger url), the flow basically works, but the Content-Type of the xhtml/Presentation part of the multipart/form-data request seems to get messed up."

So, yes, @v-yamao-msft,I should be using application/xhtml+xml.

I don't know how to do that.
I am not actively using text/plain.
I don't set text/plain anywhere.
I just forward (parts of) the body of a multipart/form-data request from a http trigger to a custom connector.

Please, tell me how to use (or force the use of) application/xhtml+xml!

augpark
Regular Visitor

@SaWu , were you ever able to figure this out? I'm trying to create a custom connector to do a similar call. I'm looking to add the PDF contents of a document into a OneNote page but it's expecting a multipart/form-data request with Presentation with a Content-Type of text/html and the file binary data with a Content-Type of application/pdf. But I'm a little unsure of how to set up this call in the custom connector. 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,375)