Q&A

Messaging API Request failed with status code 400 on template carousel

I'm sorry, i'd like to ask. I've been working on this project for about a month, and stuck on this problem for a week. I always get the 'Request failed with status code 400'. According to the docs, it is because of a bad request. I do the request the same with the working carousel, but it doesn't work. This is how i request for reply, i use node js btw:

this.client.replyMessage(event.replyToken, resp)
            .catch(err => console.log(err.message))

And this is what resp is:

[
    {
        type: 'text',
        text: 'Ini kak berita-berita yang mungkin bisa membantu kakak :D'
    },
    {
        type: 'template',
        altText: 'Carousel daftar berita',
        template: {
            type: 'carousel',
            columns: [Array]
        }
    }
]

This is how i create the columns

let columns = []
for (let berita of resp.data) {
	let text = berita.sara === 'negative' ? 'TERINDIKASI SARA' : 'TIDAK TERINDIKASI SARA'

	let title = berita.title.substring(0, 57) + "..."
	columns.push({
		// thumbnailImageUrl: berita.img,
		title: title,
		text: text,
		actions: [
			{
				type: 'uri',
				label: 'Lihat Detail',
				uri: 'https://google.com' // berita.link
			}
		]
	})
}

Thanks,

  • 0
  • 2
  • 7009
  • twitter facebook

I don't know what to say, i'm sorry i didn't read the documentation carefully. I do think that the title is 60 Character Limit and the text is 40 character limir. Thank you very very much.

  • 0

Hello,

The problem is the structure of your carousel and the size of your title. In the documents of the Carousel template, we can see "title Max: 40 characters". You should decrease the number of your substring().

// Good structure for a carousel
const response = {
		type: 'template',
		altText: 'this is a carousel template',
		template: {
				type: 'carousel',
				columns: [Array] // Array of columns Max: 10
		}
};

// Good structure for a column
const column = {
   title: 'My title', // Title Max: 40 characters
   text: 'My text', //Message text Max: 120 characters (no image or title)
			// Max: 60 characters (message with an image or title)
   actions: [
       {
          type: 'uri',
          label: 'Click',
          uri: 'https://...'
	    }
   ]
};

がんばって!

  • 0

関連する質問

    関連する質問はありません

本当によろしいですか? question.vm