Lỗi SlackBot OpenModal: “Thiếu bộ mã”
Tôi muốn thực hiện một cuộc gọi api qua Zapier để mở một Phương thức trong Slack.
Nhưng tôi luôn gặp lỗi:
ok: false
error: invalid_json
warning: missing_charset
response_metadata:
warnings:
1: missing_charset
Đây là Nội dung Yêu cầu của tôi:
{
"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"
}
}
]
}
}
Tôi đang làm gì sai?
Đây là Ảnh chụp màn hình của toàn bộ cuộc gọi:
Trả lời
Giải pháp có thể được tìm thấy trong tài liệu này :
Không thể phân tích cú pháp JSON bạn đã đưa vào nội dung POST của mình. Điều này có thể là do nó thực sự không phải là JSON hoặc có lẽ bạn đã không đặt đúng tiêu đề loại Nội dung HTTP của mình. Đảm bảo các khóa thuộc tính JSON của bạn là các chuỗi được bao bọc bằng các ký tự dấu ngoặc kép (").
Bạn chỉ cần xóa một dấu phẩy, sau đó nó sẽ hoạt động:
{
"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"
}
}
]
}
}
Bạn có thể xóa cảnh báo missing_charsetnếu bạn đặt bộ ký tự cho tiêu đề loại nội dung. Ví dụ:
Content-type: application/json; charset=utf-8