cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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
Highlighted

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

4 REPLIES 4
Highlighted
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.

 

Highlighted

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": []
}
Highlighted

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

Highlighted
Regular 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!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Users online (12,620)