SlackBot ข้อผิดพลาด OpenModal:“ Missing Charset”
Aug 23 2020
ฉันต้องการโทร api ผ่าน Zapier เพื่อเปิด Modal ใน Slack
แต่ฉันมักจะได้รับข้อผิดพลาด:
ok: false
error: invalid_json
warning: missing_charset
response_metadata:
warnings:
1: missing_charset
นี่คือเนื้อหาคำขอของฉัน:
{
"token":"XXXXXXXXX",
"trigger_id":"XXXXXXXXXX",
"dialog": {
"callback_id": "projekt-verantwortliche",
"title": "Projektverantwortliche auswählen",
"submit_label": "Request",
"state": "Limo",
"elements": [
{
"type": "users_select",
"action_id": "projekt-projektleiter",
"placeholder": {
"type":"plain_text",
"text":"Projektleiter auswählen"
},
},
{
"type": "users_select",
"action_id":"projekt-berater",
"placeholder": {
"type":"plain_text",
"text":"Berater auswählen"
}
}
]
}
}
ผมทำอะไรผิดหรือเปล่า?
นี่คือภาพหน้าจอของการโทรทั้งหมด:
คำตอบ
1 flaxel Aug 23 2020 at 19:00
สามารถดูวิธีแก้ปัญหาได้ในเอกสารนี้:
ไม่สามารถแยกวิเคราะห์ JSON ที่คุณรวมไว้ในเนื้อหา POST ของคุณได้ อาจเป็นเพราะจริงๆแล้วมันไม่ใช่ JSON หรือบางทีคุณอาจตั้งค่าส่วนหัวประเภทเนื้อหา HTTP ไม่ถูกต้อง ตรวจสอบว่าคีย์แอตทริบิวต์ JSON ของคุณเป็นสตริงที่มีเครื่องหมายอัญประกาศคู่ (")
คุณต้องลบเครื่องหมายจุลภาคเพียงตัวเดียวจากนั้นควรใช้งานได้:
{
"token":"XXXXXXXXX",
"trigger_id":"XXXXXXXXXX",
"dialog":{
"callback_id":"projekt-verantwortliche",
"title":"Projektverantwortliche auswählen",
"submit_label":"Request",
"state":"Limo",
"elements":[
{
"type":"users_select",
"action_id":"projekt-projektleiter",
"placeholder":{
"type":"plain_text",
"text":"Projektleiter auswählen"
}
},
{
"type":"users_select",
"action_id":"projekt-berater",
"placeholder":{
"type":"plain_text",
"text":"Berater auswählen"
}
}
]
}
}
คุณสามารถลบคำเตือนได้missing_charsetหากคุณตั้งค่าชุดอักขระสำหรับส่วนหัวประเภทเนื้อหา ตัวอย่างเช่น:
Content-type: application/json; charset=utf-8