当前,我拥有Microsoft Teams机器人,该机器人具有一个扩展按钮,可在iframe中打开HTML页面。在HTML页面上,有一个带有提交按钮的表单,用于提交用户输入的信息。我遇到的问题是,当用户单击“提交”按钮时,它不会发出HTTP POST请求。我已经在团队外部测试了iframe,并且效果很好。我想知道这是否与iframe或实际HTML页面设置或其他问题有关。谢谢!
答案 0 :(得分:1)
您是在使用microsoftTeams.tasks.submitTask()
函数,还是只是尝试直接进行POST?我怀疑你正在做后者。团队必须负责实际的提交,因为否则它不知道POST曾经发生过,因为它发生在<iframe>
中。
如果这是您的问题,那么这里是一个示例。这是在Azure上运行的示例的the JS/Pug code的摘录;我刚刚测试了它,效果很好:
[...]
function validateForm() {
let customerInfo = {
name: document.forms["customerForm"]["name"].value,
email: document.forms["customerForm"]["email"].value,
favoriteBook: document.forms["customerForm"]["favoriteBook"].value
}
guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
let password = document.getElementById("pw").value;
if (guidRegex.test(password)) {
microsoftTeams.tasks.submitTask(customerInfo, password); // hidden feature to test bogus completion appId
}
else {
microsoftTeams.tasks.submitTask(customerInfo, "#{appId}"); //- appId is passed at render time in tabs.ts
}
return true;
}
[...]
div(class='surface')
div(class='panel')
div(class='font-semibold font-title') Enter new customer information:
form(method='POST' id="customerForm" action='/register' onSubmit="return validateForm()")
div
div.form-group(class="form-field-input" style="margin-bottom: 10px; margin-top: 10px")
label(for='name') Name:
input#name.form-control.input-field(type='text', placeholder='first and last' name='name' tabindex=1 autofocus)
div.form-group(class="form-field-input" style="margin-bottom: 10px;")
label(for='email') Email:
input#email.form-control.input-field(type='email', placeholder='name@email.com' name='email' tabindex=2)
div.form-group(class="form-field-input" style="margin-bottom: 10px;")
label(for='favoriteBook') Favorite book:
input#favoriteBook.form-control.input-field(type='text', placeholder='title of book' name='favoriteBook' tabindex=3)
div.form-group(class="form-field-input" style="margin-bottom: 10px;")
label(for='pw') Password:
input#pw.form-control.input-field(type='password' name='password' tabindex=4)
div.form-group(class="form-field-input" style="margin-bottom: 10px;")
label(for='pw2') Confirm password:
input#pw2.form-control.input-field(type='password' name='confirmPassword' style="margin-bottom: 10px;" tabindex=4)
button.btn.button-primary(type='submit' tabindex=5) Sign up
答案 1 :(得分:0)
这很可能与您的应用清单文件中的有效域列表有关。您正在使用App Studio吗?如果是这样,则需要在“域和权限”部分中将POST端点列为有效域(只是域部分,而不是完整URL)。
如果您不使用App Studio,或者只是想获得更多参考,请参阅here