Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call failing because "Charset=UTF-8" appended to Content-Type header #428

Open
joyfullservice opened this issue Mar 19, 2020 · 2 comments · May be fixed by #429
Open

Call failing because "Charset=UTF-8" appended to Content-Type header #428

joyfullservice opened this issue Mar 19, 2020 · 2 comments · May be fixed by #429

Comments

@joyfullservice
Copy link

I am building an integration to a MIVA webstore and was baffled by why the API calls were not working from VBA-Web, but the identical call worked just fine from VSCode rest client.

After tracing the call in fiddler, I discovered the problem. For some reason the calls made through VBA-Web are changing the Content-Type header from application/json to application/json; Charset=UTF-8. The endpoint that I am calling is expecting exactly application/json, so it returns a failure base on the "wrong content type".

image

Why would it be appending the charset parameter, and how can I prevent it from doing so?

@zgrose
Copy link

zgrose commented Mar 19, 2020

Only place i see charset= in the current code is in FormatToMediaType which has. Maybe do a Search in your project and see if you find something else?

Public Function FormatToMediaType(Format As WebFormat, Optional CustomFormat As String) As String
    Select Case Format
    Case WebFormat.FormUrlEncoded
        FormatToMediaType = "application/x-www-form-urlencoded;charset=UTF-8"
    Case WebFormat.Json
        FormatToMediaType = "application/json"
    Case WebFormat.xml
        FormatToMediaType = "application/xml"
    Case WebFormat.Custom
        FormatToMediaType = web_GetConverter(CustomFormat)("MediaType")
    Case Else
        FormatToMediaType = "text/plain"
    End Select
End Function

@joyfullservice
Copy link
Author

Thanks! I found https://stackoverflow.com/questions/35641883/winhttp-winhttprequest-adding-to-the-content-type which seems to be pointing me in the right direction... Doing some testing now. I will post back if I am able to find a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants