Skip to content

UnsupportedMediaType when patching ingress #443

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

Closed
SaschaHeyer opened this issue May 5, 2020 · 4 comments
Closed

UnsupportedMediaType when patching ingress #443

SaschaHeyer opened this issue May 5, 2020 · 4 comments

Comments

@SaschaHeyer
Copy link

SaschaHeyer commented May 5, 2020

Hi

when patching a ingress we get the following error message

{
      kind: 'Status',
      apiVersion: 'v1',
      metadata: {},
      status: 'Failure',
      message: '415: Unsupported Media Type',
      reason: 'UnsupportedMediaType',
      details: {},
      code: 415
    }

Kubernetes Version: 1.14.10-gke.27

@brendandburns
Copy link
Contributor

This is almost certainly because the Content-type header is set to application/json instead of application/strategic-merge-patch+json or something similar.

See #440 which discussed the same issue.

@brendandburns
Copy link
Contributor

Closing this issue since I believe the question is answered. If you still have problems, please place them in #440

@saxicek
Copy link

saxicek commented May 14, 2020

It would be good to include full patch example in examples directory. I also got the same issue. My fixed code looks like:

  const k8sNetworkingApi = kc.makeApiClient(k8s.NetworkingV1beta1Api);
  const patchedIngress = {
    metadata: {
      annotations: {
        'nginx.ingress.kubernetes.io/cors-allow-origin': '*'
      }
    }
  }
  k8sNetworkingApi.patchNamespacedIngress(ingressName, namespace, patchedIngress, undefined, undefined, undefined, undefined,
    { headers: { 'content-type': 'application/merge-patch+json' } })

@brendandburns
Copy link
Contributor

We would happily take a PR adding a complete patch example to the examples directory.

I filed: #450

To track this, @saxicek if you have the time to create a PR that would be awesome!

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

No branches or pull requests

3 participants