Skip to content

Overwrite Content-Type #2099

Closed
Closed

Description

We got a server that only accepts Content-Type: application/json and not Content-Type: application/json; charset=utf-8;

OkHttp keeps generating application/json; charset=utf-8; when we do the following json post

MediaType type = MediaType.parse("application/json");
String json = "{"APIRequests"}";
Request request = new Request.Builder()
.url(apiURL)
.post(RequestBody.create(type, json))
.build();
Response response = client.newCall(request).execute();
String html = response.body().string();

and returns an error. Is there any posibility to overwrite the content-type and not use the generated one from MediaType.parse?

Server it's a public one and i do have no control over it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions