Cordial API "Unsupported Media Type" error: fix the Content-Type header
Cordial returns "Unsupported Media Type" when a request's Content-Type header is missing or is not application/json or application/x-www-form-urlencoded. Set the header to application/json, send a valid JSON body, then enable API logging on the key and read the Account Monitoring page to see what Cordial received.
Sohail Hussain8 min readShort answer
- Send the header Content-Type: application/json on every Cordial API request, and make sure the body is valid JSON that is serialized only once.
- If the header looks right in your code and the error stays, enable API logging on the key and read the Account Monitoring page to see what Cordial actually received.
You sent a request to the Cordial API and got this back:
Unsupported Media Type: Content-Type header must be application/json or application/x-www-form-urlencoded.
This is a Cordial API error, so nothing here depends on your email platform. I'm covering it together with INVALID_JSON_PROVIDED and RECORD_NOT_FOUND, because the same few mistakes in headers and payload types tend to produce all three. Cordial lists its 4xx error keys in its "Global API error responses" help article; check it for the current list, since it can change after November 2026.
Why the error happens
HTTP status 415 means the server understood the request but refuses the body format. Cordial accepts two content types:
| Content-Type | Body it expects |
|---|---|
application/json | A JSON document |
application/x-www-form-urlencoded | key=value&key2=value2 pairs |
Anything else should fail: a missing header, text/plain, multipart/form-data, or a mistyped application/json. The check runs before Cordial looks at your data, so the error says nothing about whether your contact fields or keys are right.
The causes, most common first:
- The header is missing. Many HTTP clients only set Content-Type automatically when you pass an object they recognize. Pass a pre-built string and they may send nothing, or
text/plain. - Something between you and Cordial rewrites the header. API gateways, serverless wrappers, no-code tools with a custom request step, and form builders that default to
multipart/form-dataare the usual culprits. - The body is not valid JSON. The header passes, then you get
INVALID_JSON_PROVIDED. - A field has the wrong type. The JSON parses but a value fails validation.
- The record does not exist. That gives
RECORD_NOT_FOUND, which is unrelated to headers.
Fix 1: set the Content-Type header
Confirm the problem first by printing the outgoing request. With curl, add -v and look for the Content-Type line among the request headers (the lines starting with >).
The shape of a correct request:
curl -X POST "https://api.example.com/your-cordial-endpoint" \
-u "YOUR_API_KEY:" \
-H "Content-Type: application/json" \
-d '{"channels":{"email":{"address":"jane@example.com"}}}'
Take the base URL, path and authentication details from Cordial's own API reference; the host depends on your account, so don't copy the placeholder above. The part that matters here is the -H line.
Fixes by client:
- curl: add
-H "Content-Type: application/json". With-dalone, curl sendsapplication/x-www-form-urlencoded. Cordial accepts that type, but your JSON string is then read as form data and fails in a different way. - Python requests: use
requests.post(url, json=payload, auth=(key, "")). Thejson=argument sets the header for you. If you usedata=json.dumps(payload), set the header yourself. - Node fetch or axios: with fetch, set
headers: { "Content-Type": "application/json" }and passJSON.stringify(payload)as the body. Axios sets the header when you pass a plain object. - Postman: under Body, choose raw, then JSON from the dropdown. Raw with Text sends
text/plain.
Form encoding hides the real problem
If you send JSON with the form-encoded header, Cordial will not return a 415, because that type is allowed. You get a different error instead, so a changed error message after a header fix is progress, not a new bug.
Fix 2: find a proxy or tool that changes the header
If the same request works from curl but fails from your app, something in between is changing it. Compare the raw request from your app with the working curl request, header by header.
In a no-code tool, look for a setting named something like body type or content type, and switch it to JSON. In a gateway, check whether a transformation or default-header rule overrides the value.
Fix 3: INVALID_JSON_PROVIDED
When the header is right but the body is not parseable JSON, expect INVALID_JSON_PROVIDED. Check for:
- Single quotes instead of double quotes around keys and strings.
- Trailing commas after the last item.
- Unescaped quotes or line breaks inside a string value.
- A body serialized twice, so it arrives as one long quoted string.
- A byte order mark or stray characters before the opening brace.
Paste the exact body you send into a JSON validator, or run it through python -m json.tool. Test the string your code actually sends, not the one you wrote in the editor.
Double serialization is easy to miss. If your logs show the body starting with "{\"channels\", you called JSON.stringify (or json.dumps) on something already stringified. Serialize once.
Fix 4: wrong JSON types
Developers also hit 4xx errors when a field is valid JSON but the wrong type: a number sent as a string, an object where a list is expected, or the reverse. The header check and the syntax check both pass, and the error comes from field validation. The error key and message in the response should point to the field; compare it with the documented type for that endpoint in Cordial's API reference.
Fix 5: RECORD_NOT_FOUND
RECORD_NOT_FOUND is not a header problem. It means the record you addressed does not exist for the account the key belongs to. Common reasons:
- The ID or email in the URL is wrong, or has an encoding problem (an unescaped
+or@in a path). - The key belongs to a different Cordial account than the one holding the record, such as a test account.
- The record was deleted, or never created because an earlier create call failed.
Look up the record in the Cordial UI under the same account as the API key. If it is not there, the API is right.
Quick reference: error, cause, fix
| Response | Likely cause | Fix |
|---|---|---|
| Unsupported Media Type (415) | Missing or wrong Content-Type | Send application/json |
INVALID_JSON_PROVIDED | Body is not valid JSON | Validate the sent string; serialize once |
| Field validation 4xx | Right syntax, wrong type | Match documented field types |
RECORD_NOT_FOUND | Record absent for this key's account | Check the ID and the account |
Find the real cause with API logging
When reading your own code gets you nowhere, let Cordial show you the request it saw:
- In Cordial, open the API key you are using and enable API logging for it. Menu locations can change, so search the Cordial help center for "API keys" if you can't find it.
- Resend the failing request.
- Open the Account Monitoring page and find the entry for that call.
- Compare the logged request with what you meant to send. A missing or altered Content-Type, an empty body or a mangled payload should be visible there.
- Turn logging off afterward if you don't want request data retained; check Cordial's docs for what is stored and for how long.
I'd reach for this first when the header looks right in your code but Cordial disagrees.
Checklist before you resend
Content-Type: application/jsonappears in the headers actually sent, not just in your code.- The body parses as JSON and is serialized once.
- Field types match the endpoint's documentation.
- The API key belongs to the same Cordial account as the record.
- The request works from curl if it fails from your app.
Prevent it
- Set the Content-Type header in one shared API client function instead of per call.
- Log the outgoing headers and body length in your own app for failed calls, with secrets removed.
- Validate payloads against the documented field types before sending.
- Use separate keys per environment, so a
RECORD_NOT_FOUNDpoints at the data and not at the wrong account.
If nothing works
If a correct header and valid JSON still return the error, open a ticket with Cordial support. Include the timestamp with timezone, the endpoint and HTTP method, the full error response, the API key's name (never the secret), and the Account Monitoring log entry. Say whether the request succeeds from curl.
Subject: API returns "Unsupported Media Type" despite Content-Type: application/json
Hi Cordial support,
Our API requests to {endpoint} ({method}) return:
"Unsupported Media Type: Content-Type header must be application/json or application/x-www-form-urlencoded."
Timestamp: {date, time, timezone}
API key name: {key name}
Account Monitoring entry: {attached screenshot or text}
Request headers sent: {headers, secrets removed}
Works from curl: {yes/no}
Already tried: set the header explicitly, validated the JSON body, checked for proxies rewriting headers.
Can you tell us what Content-Type your side received?
Common questions
Is the 415 error about my data or my headers?
Your headers. Cordial rejects the request before reading the body, so contact fields and values are not checked yet.
Why did the error change after I fixed the header?
The request now gets past the content-type check and meets the next one, usually JSON parsing (INVALID_JSON_PROVIDED) or field validation. Work through the fixes in order.
Can I use form encoding instead of JSON?
Cordial accepts application/x-www-form-urlencoded, but nested contact data is much easier to get right as JSON, so I'd stick with application/json.
Does RECORD_NOT_FOUND mean my request format is wrong?
No. The format was accepted; the record you addressed is missing for that key's account.
Explore: Email Marketing Strategy
Related Articles
ActiveCampaign n8n error 301 on create contact: causes and fixes
A 301 from the ActiveCampaign node means the request went to a URL that redirects, so start with the API URL in your n8n credential. Copy it from Settings, then Developer, and check the scheme and path. Zapier 403 and cURL error 28 behind Cloudflare have different causes, covered below.
"Stage not on allowlist": Apollo to HubSpot sync fix
The error "Stage not on allowlist" means the contact's Apollo stage is not on the list of stages permitted to push to HubSpot. Open the HubSpot integration in Apollo, go to the Sync tab, and add that stage under "Stages for push contacts". Lifecycle stage mapping is a separate setting.
Salesmate "Authorization with Gmail failed": Gmail IMAP fix
Salesmate shows "Authorization with Gmail failed" when it can't read your Gmail account over IMAP. In Gmail settings, enable IMAP, choose "Do not limit the number of messages in an IMAP folder", and show All Mail in IMAP. Then reconnect the account in Salesmate. Other causes are covered below.
AWeber export "Stop Status" and "Stop Time" columns explained
In an AWeber subscriber export, a non-empty Stop Time and a non-zero Stop Status most likely mean the person has stopped receiving your mail, usually because they unsubscribed. AWeber doesn't explain the columns in the file, so verify against a few known unsubscribes, then import those rows as blocked, not subscribed.
Ready to supercharge your email marketing?
Start sending smarter emails with AI-powered campaigns. No credit card required.
Get Started Free