lennaert
I added header = "Content-Type", value = "application/json"then I got error "400Bad Request"
"400 Bad Request
The HyperText Transfer Protocol (HTTP) 400 Bad Request response status code indicates that the server cannot or will not process the request due to something that is perceived to be a client error (for example, malformed request syntax, invalid request message framing, or deceptive request routing)."
Going by this, you likely have an error in the format of your request (how its build up) Compare the output string with a working example.
IF you test in a browser, with the browser development tools you can check the content of your actual request.
When you have the app running, (in chrome) press ctr + shift + j, select network tab. Below should be a list or a link which performed the attempted request. When you click it, the tabs next to it have all sorts of info, from the actual headers to the content of your request.