Admin requests fail when content type includes a charset #216

Closed
opened 2025-12-29 14:25:23 +01:00 by adam · 3 comments
Owner

Originally created by @paulroub on GitHub (Sep 30, 2019).

Originally assigned to: @StefH on GitHub.

When POSTing a mapping request from C#, by default a "charset=utf-8" parameter is added to the Content-Type header. This causes the request to fail with

{"Status":"No matching mapping found"}

Remove the charset and the request succeeds.

Easily reproducible with curl. This succeeds:

URL=http://localhost:9091/__admin/mappings

JSON='{
    "request": {
        "method": "GET",
        "url": "/some/thing"
    },
    "response": {
        "status": 200,
        "body": "Hello world!",
        "headers": {
            "Content-Type": "text/plain"
        }
    }
}'

curl \
    -H "Content-Type: application/json" \
    -d "$JSON" \
    -iv \
    "$URL"

whereas this fails:

URL=http://localhost:9091/__admin/mappings

JSON='{
    "request": {
        "method": "GET",
        "url": "/some/thing"
    },
    "response": {
        "status": 200,
        "body": "Hello world!",
        "headers": {
            "Content-Type": "text/plain"
        }
    }
}'

curl \
    -H "Content-Type: application/json; charset=utf-8" \
    -d "$JSON" \
    -iv \
    "$URL"
Originally created by @paulroub on GitHub (Sep 30, 2019). Originally assigned to: @StefH on GitHub. When POSTing a mapping request from C#, by default a "charset=utf-8" parameter is added to the Content-Type header. This causes the request to fail with > {"Status":"No matching mapping found"} Remove the charset and the request succeeds. Easily reproducible with curl. This succeeds: ```sh URL=http://localhost:9091/__admin/mappings JSON='{ "request": { "method": "GET", "url": "/some/thing" }, "response": { "status": 200, "body": "Hello world!", "headers": { "Content-Type": "text/plain" } } }' curl \ -H "Content-Type: application/json" \ -d "$JSON" \ -iv \ "$URL" ``` whereas this fails: ```sh URL=http://localhost:9091/__admin/mappings JSON='{ "request": { "method": "GET", "url": "/some/thing" }, "response": { "status": 200, "body": "Hello world!", "headers": { "Content-Type": "text/plain" } } }' curl \ -H "Content-Type: application/json; charset=utf-8" \ -d "$JSON" \ -iv \ "$URL" ```
adam added the bug label 2025-12-29 14:25:23 +01:00
adam closed this issue 2025-12-29 14:25:23 +01:00
Author
Owner

@StefH commented on GitHub (Oct 2, 2019):

You can try MyGet version:
WireMock.Net.1.0.32-ci-11942.nupkg

@StefH commented on GitHub (Oct 2, 2019): You can try MyGet version: WireMock.Net.1.0.32-ci-11942.nupkg
Author
Owner

@StefH commented on GitHub (Oct 5, 2019):

@paulroub did you have time to test?

@StefH commented on GitHub (Oct 5, 2019): @paulroub did you have time to test?
Author
Owner

@paulroub commented on GitHub (Oct 5, 2019):

Yes, sorry - all good!

On Sat, Oct 5, 2019 at 3:53 AM Stef Heyenrath notifications@github.com
wrote:

@paulroub https://github.com/paulroub did you have time to test?


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/WireMock-Net/WireMock.Net/issues/350?email_source=notifications&email_token=AAEQZUZFPPMPLBXW25JGIF3QNBBW5A5CNFSM4I35U5Y2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEANMYWY#issuecomment-538627163,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEQZU2W3C7H4DHFLZOBRMDQNBBW5ANCNFSM4I35U5YQ
.

@paulroub commented on GitHub (Oct 5, 2019): Yes, sorry - all good! On Sat, Oct 5, 2019 at 3:53 AM Stef Heyenrath <notifications@github.com> wrote: > @paulroub <https://github.com/paulroub> did you have time to test? > > — > You are receiving this because you were mentioned. > > > Reply to this email directly, view it on GitHub > <https://github.com/WireMock-Net/WireMock.Net/issues/350?email_source=notifications&email_token=AAEQZUZFPPMPLBXW25JGIF3QNBBW5A5CNFSM4I35U5Y2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEANMYWY#issuecomment-538627163>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAEQZU2W3C7H4DHFLZOBRMDQNBBW5ANCNFSM4I35U5YQ> > . >
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#216