I’m trying to use the HTTP Request node in n8n to reply to tweets using the official X (Twitter) API with OAuth2 authentication. I’ve successfully fetched the tweet IDs and generated the reply text using a code node.
Now I’m trying to post a reply like this:
json
CopyEdit
{
"text": "{{ $json.output }}",
"reply": {
"in_reply_to_tweet_id": "{{ $('Code').item.json.tweetId }}"
}
}
I’m using POST https://api.twitter.com/2/tweets with:
X OAuth2 APIcredentialJSON/RAW Parametersturned ONSend Body= ONBody Content Type= JSON
But I keep getting the error:
“JSON parameter needs to be valid JSON” or sometimes “Requests with bodies must have content-type of application/json.”
I’ve confirmed:
- The OAuth2 app has
tweet.writescope - The tweet ID is valid
- The JSON structure matches X’s API docs
- I’m not sending headers manually (leaving them to OAuth2)
Not sure what I’m missing — any help appreciated!
Share the output returned by the last node
Information on your n8n setup
- n8n version:
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system:
