Google App Script - Create Ticket Error invalid_content_type


I want to create a Google app script to create tickets, but I am receiving the following error: {“code”:“invalid_content_type”,“message”:“Content-Type header is set to application/x-www-form-urlencoded. It should be set to application/json”}

I’m not sure why because I set the type correctly in this code. Any thoughts?

function createTicket(){
let url = ‘https://domain/api/v2/tickets/’;
let headers = {
“Authorization”: "Basic " + Utilities.base64Encode(‘*****’),
“contentType”: “application/json”,
muteHttpExceptions: true
let options = {
‘method’: ‘POST’,
‘headers’: headers,
‘muteHttpExceptions’: true,
‘payload’: JSON.stringify({
“description”:“Testing API”,
“subject”:“Help needed desparately”,
“status”: “Open” })
response = UrlFetchApp.fetch(url,options);

Thanks in advance!

Hello, isn’t that maybe you’re misspelling the header? I see that you’re calling it “contentType” and not “Content-Type”.


That was it, I was so focused on the content type that I missed the header error.

You’re welcome! Happens to everyone to go in tunnel vision from time to time, I have that problem too.