Request node js and twitch api

I’m trying:

const options = {
    method: "POST",
    url: 'ссылка',
    form: {
      "type": "...",
      "version": "1",
      "condition": {
        "broadcaster_user_id": "1234"
      },
      "transport": {
        "method": "webhook",
        "callback": "https://example.com/callback",
        "secret": "..."
      }
    },
    headers: {
      'Authorization': '... ',
      'Client-Id': '...',
      'Content-Type': 'application/json'
    }
  };

But I keep getting an error: missing or unparseable subscription condition

What am I doing wrong?

You declared application/json but (likely) sent application/x-www-form-urlencoded

So try

const options = {
    method: "POST",
    url: '',
    body: JSON.stringify({ ...snip ... })
    },
    headers: {
      'Authorization': '... ',
      'Client-Id': '...',
      'Content-Type': 'application/json'
    }
  };

It works! Thanks a lot!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.