cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frank37
Helper I
Helper I

Custom Connector: Header "content-type" not sent to service

I would like to connect to an RestAPI-Service, which needs the header information:

"content-type": "application/x-www-form-urlencoded"
but have problems using it as well in Flow as in PowerApps Smiley Sad
Error code/status is 415:    Unsupported Media Type     Content type '' not supported
 
To reproduce the problem, I tested it with the Postman Echo Server and two header keys: "content-type" and "MyContentType":
In Postman both Key/Value are echoed:
 
Postman.jpg

 

I generate a custom connector with these two header parameters

 

CustomConnector.jpg

and the default response 200:

Response200.jpg

 

The custom connector test shows no error and no problem: both keys are in the response:

CustomConnectorTest.jpg

 

Problem:

If I use it in a Flow "content-type" is missing, only "MyContentType" is accessable:

FlowTest.jpg

 

I've testet the runtime server input: both parameters are transfered to the azure platform

{
  "method":"post",
  "headers":{
    "Content-Type":"application/x-www-form-urlencoded",
    "MyContentType":"application/x-www-form-urlencoded"
  },
  "path":"/post",
  "host":
  {
    "api":
    {
      "runtimeUrl":"https://europe-002.azure-apim.net/apim/flowposttest-5f7e5f68ae5b1cf2d2-5f79e327c051ec9794"
    },
    "connection":
    {"name":"/providers/Microsoft.PowerApps/apis/shared_flowposttest-5f7e5f68ae5b1cf2d2-5f79e327c051ec9794/connections/e38ffb06-9eb2-451d-a51a-5509-8628e957"
    }
  },
  "authentication":
  {
    "scheme":"Key",
    "parameter":"*sanitized*",
    "type":"Raw"
  }
}

Why is the Azure Server deleting the "content-type" parameter?

1 ACCEPTED SOLUTION

Accepted Solutions

Here is the solution from GonzaloR (worked for me 👍)

 

https://powerusers.microsoft.com/t5/General-Power-Automate/Custom-connector-action-with-x-www-form-u...

 

  1. Click "New Policy"
  2. Name your policy
  3. Select "Set HTTP header"
  4. Select the Operations (Actions) that require this header
  5. Header name: "content-type"
  6. Header Value: "application/x-www-form-urlencoded"
  7. Action if header exists: "override"
  8. Run policy on: "Request"

 

View solution in original post

5 REPLIES 5
v-alzhan-msft
Community Support
Community Support

Hi @Frank37 ,

 

Have you created the "content-type" for the output of the custom connector?

Could you please take a try to add a Compose action under custom connector, and check if you could add am expression or a dynamic content for the "content-type"?

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi Alice,

 

yes, "content-type" is defined for the output of the custom connector, but only to show, that the azure platform is deleting the HTTP-header-parameter  "content-type"

 

IT's not possible to add a Compose Action, which changes the HTTP-header of the custom connector action. You can only change the url parameters.

 

Here is a sample Swagger-File for a custom connector (OpenAPI)

 

If using the custom connector test funktion, the "content-type" header-parameter is sent to the server (and echoed in the reply).

If using this connector in flow (or PowerApps), the azure platform deletes the  "content-type" header-parameter (why?) and in the echo reply the parameter is missing

 

{
  "swagger": "2.0",
  "info": {
    "description": "Postman Echo Server",
    "version": "0.1",
    "title": "MyTest2"
  },
  "host": "postman-echo.com",
  "basePath": "/",
  "schemes": [
    "https"
  ],
  "consumes": [],
  "produces": [],
  "paths": {
    "/post": {
      "post": {
        "consumes": [
          "application/x-www-form-urlencoded"
        ],
        "produces": [
          "application/json"
        ],
        "parameters": [
           {
            "name": "Content-Type",
            "in": "header",
            "required": true,
            "type": "string",
            "default": "application/x-www-form-urlencoded",
            "x-ms-visibility": "internal"
          },
          {
            "name": "MyContentType",
            "in": "header",
            "required": true,
            "type": "string",
            "default": "application/x-www-form-urlencoded",
            "x-ms-visibility": "internal"
          }
        ],
        "responses": {
          "200": {
            "description": "default",
            "schema": {
              "type": "object",
              "properties": {
                "url": {
                  "type": "string",
                  "description": "url"
                },
                "headers": {
                  "type": "string",
                  "description": "MyContentType"
                },
                "Content-Type": {
                  "type": "string",
                  "description": "Content-Type"
                }
              }
            }
          }
        },
        "summary": "Echo Server Test",
        "description": "Echo Server Test",
        "operationId": "EchoServerTest"
      }
    }
  },
  "parameters": {},
  "responses": {},
  "securityDefinitions": {},
  "security": [],
  "tags": []
}

Here is the solution from GonzaloR (worked for me 👍)

 

https://powerusers.microsoft.com/t5/General-Power-Automate/Custom-connector-action-with-x-www-form-u...

 

  1. Click "New Policy"
  2. Name your policy
  3. Select "Set HTTP header"
  4. Select the Operations (Actions) that require this header
  5. Header name: "content-type"
  6. Header Value: "application/x-www-form-urlencoded"
  7. Action if header exists: "override"
  8. Run policy on: "Request"

 

View solution in original post

derb
Frequent Visitor

Thank you sooo much!  You solved my problem with my custom connector that I could not figure out! Virtual hugs and joy! I have been trying to modify the URL by changing the sample input for about an hour without success... This worked like a charm!

jackp514
Frequent Visitor

To any one still struggling with this issue, none of these solutions fixed the error for me. The only thing that worked was putting SOMETHING in the "body"

 

If you put "{ }" in the body it seems to work now.

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,071)