0

GupShup 経由で画像を送信しようとしています。私は彼らのサンドボックスを使用しています。私のバックエンドは、feathersjs を使用した node.js です。しかし、それは私にこのエラーを返しています:

Response {
  size: 0,
  timeout: 0,
  [Symbol(Body internals)]: {
    body: PassThrough {
      _readableState: [ReadableState],
      readable: true,
      _events: [Object: null prototype],
      _eventsCount: 2,
      _maxListeners: undefined,
      _writableState: [WritableState],
      writable: false,
      allowHalfOpen: true,
      _transformState: [Object],
      [Symbol(kCapture)]: false
    },
    disturbed: false,
    error: null
  },
  [Symbol(Response internals)]: {
    url: 'https://api.gupshup.io/sm/api/v1/msg',
    status: 400,
    statusText: 'Bad Request',
    headers: Headers { [Symbol(map)]: [Object: null prototype] },
    counter: 0
  }
}

これは画像を送信するためのコードです

const form = new URLSearchParams();
  form.append('channel', 'whatsapp');
  form.append('destination', destination);
  form.append('source', app.get('GUPSHUP_NUMBER'));
  form.append('message.payload', JSON.stringify(message));
  form.append('src.name', 'OneAccess');
  console.log(form);
  try {
    const res = await fetch('https://api.gupshup.io/sm/api/v1/msg', {
      method: 'POST',
      body: form,
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        apikey: app.get('GUPSHUP_API'),
      },
    });

    console.log('result message', res);
  } catch (err) {
    console.log('errro sending msg', err);
  }

これは私が送信しようとしているメッセージです

message: {
        type: 'image',
        originalUrl:
          'https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg',
        previewUrl:
          'https://images.pexels.com/photos/248797/pexels-photo-248797.jpeg',
        caption: 'Sample image',
      },

誰でも私を助けることができますか?

4

1 に答える 1