update via REST returns 415
Asked by balvey27:

I've gotten this to work in the past but for some reason i'm no longer able to update our wiki via API, i'm continually getting a 415 response.

I'm using python3 and I've tried via requests package and the atlassian Confluence methods. Both return 415 regardless if I supply content-type in my header or not. Actually using '''from atlassian import Confluence''' I'm not even sure how to supply content-type, the docs are not that good and I'm assuming it defaults to application/json.

The GET calls return with no problem, it's just the PUT method that is giving me issues.

```
raise HTTPError(http_error_msg, response=self)

requests.exceptions.HTTPError: 415 Client Error:  for url: https://confluence.servers.xxxxx/rest/api/content/123455667
```


Answers:
author: balvey27
body: was an internal problem with a server move and path names changing


author: chilyanin
body: [@balvey27](/t5/user/viewprofilepage/user-id/4290416) are your python put requests works fine now ?


author: WW
body: The problem would be easier to diagnose if we could see exactly what you're sending.

I'm not sure what '''from atlassian import Confluence''' is, but Content-Type can be supplied as a header like any other header.

In python, it'd be something like:

    response=requests.put(
        "https://www.myconfluence.com/", 
        headers={"Content-Type":"application/json"},
        data ={'key':'value'}
    )

Is the problem happening for every page you try with different content? It's possible you have some weird character(s) in the Json you're trying to PUT.

You can also see [REST API: "Error 415 Unsupported Media Type"](https://confluence.atlassian.com/fishkb/rest-api-error-415-unsupported-media-type-313468261.html)

comments: author: balvey27
body: sorry, it's the atlassian-python-api package for python. it's building the requests calls internally, and it doesn't look like there's an option to pass custom headers, but it does appear to set the content-type to application/json

I've tried even sending a simple \<p\>sometext\</p\> string for the data and it returns 415. I've tried multiple pages as well.

and I've built my own requests calls but they have the same results. I can pull data fine though, page_exists, and doing a GET on basic information works as it should.

beginning to wonder if it's a bug in this version. we're on 7.3.4. It's been a while since I successfully updated a page, and I'm not sure if it was an earlier version.


author: WW
body: Are you able to do any other PUT/POST/DELETE actions?

In that link I posted in my answer, it also says:
> Sometimes making cURL requests to http addresses behing SSL would also cause this 415 error

I *think*it's supposed to say "behind" (or maybe "being"?).

I don't really understand what that means, though, either way it's spelled. When doing a google search on error 415 SSL, you'll see some results that say that the error could be related to something with an SSL certificate like [this page](https://windorks.wordpress.com/2015/04/06/how-to-get-rid-of-adfs-event-415/). No idea how to fix any of that, but it might help lead you to a fix.


author: balvey27
body: Thank you for the response, I have found the issue and it was nothing to do with content. Our wiki is ran internally and they moved to a new server, the redirect they had in place got dropped and post/put actions were not being handled by it properly.

That said, my 415 is now resolved, but now I'm getting 400 errors and think it's due to size limitations of the amount of data i'm trying to update it with. That or there is a bad character in the data.


author: WW
body: I'm glad you were able to find the issue. :)


Tags: api

content

server