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

HTTP POST BadRequest: The character set provided in ContentType is invalid

Hope someone can help I've been banging my head against this for days now.

 

Scenario

Uploading a document to an API using HTTP.

 

The API requires the following information:

 

 

 

POST https://api-specificEndpoint.com/v1/documents/upload HTTP/1.1
Host: myhost.com
api_key=123&workflow_id=456&userfile={file}

 

 

 

The API will throw a 307 redirect and come back with

 

 

<?xml version="1.0" encoding="UTF-8"?>
<documents_response>
    <status>203</status>
    <message>userfile is not specified</message>
    <url>https://web1-region.specificEndpoint.com/v1/documents/upload/UBqvQjgkIxReOHh2t94w.8BH23wqGQDIhO64XA_qrbmmvX3yrGKiEr0LWrGmYiS5MXFLsYBTv.XV8ax5Xg_NqgP41P2S0Lgv</url>
    <expire>1408672099</expire>
</documents_response>

 

 

So I take the URL passed back and resubmit.

Postman takes the response URI and can successfully upload a file to that endpoint. However the same trick in Power Automate fails on the second POST request with: 

BadRequest. Http request failed: 'The character set provided in ContentType is invalid. Cannot read content as string using an invalid character set.'.

 

Here's the body of the second request:

 

 

{
    "inputs": {
        "method": "POST",
        "uri": "@variables('RegionalURL')",
        "body": {
            "$content-type": "multipart/form-data",
            "$multipart": [
                {
                    "headers": {
                        "Content-Disposition": "form-data; name=\"api_key\""
                    },
                    "body": "@binary(variables('pAPIKey'))"
                },
                {
                    "headers": {
                        "Content-Disposition": "form-data; name=\"workflow_id\""
                    },
                    "body": "@binary(variables('pWorkflowID'))"
                },
                {
                    "headers": {
                        "Content-Disposition": "form-data; name=\"userfile\"; filename=\"Test.pdf\""
                    },
                    "body": {
                        "$content-type": "application/pdf",
                        "$content": "@base64(outputs('Get_file_content_using_path')?['body'])"
                    }
                }
            ]
        }
    }
}

 

 

 

I created a Flow that is triggered by a HTTP request to catch the outputs of Postman and the flow I'm trying to create. When the URI is set to the HTTP request test flow no problem and the output is duly received. When I set the URI to the URL returned from the 203 redirect, it gives the BadRequest content-type error before even sending.

 

What am I doing wrong?

 

Any help appreciated.

 

1 REPLY 1
markjones
Frequent Visitor

Going to report this as a bug. The request is in fact successful. However the response cannot be read due the runtime bad request error.

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Users online (47,388)