繁体   English   中英

Drupal 网络表格 REST

[英]Drupal Webform REST

我正在尝试使用 Drupal Webform REST。我收到错误消息“需要‘restful post webform_rest_submit’许可。” 在浏览器控制台上。 如前所述,我已启用模块和 REST 资源。 我使用了Authorization,在Postman生成的Auth,使用basic auth。 我正在努力在 postman 中使用“x-csrf-token”。我想使用匿名用户提交表单。 我还需要授权吗,只是令牌不能在同源上工作吗?

const handleSubmit = async (e) => {
    e.preventDefault(); 

    await axios({
      method: 'GET',
      url: `${baseurl.URL}/session/token`,
      headers: {
        'Accept': 'application/vnd.api+json',
      }
    })
    .then(response =>  response)
    .then((token)=>{
      console.log("CSRF TODKEN", token.data);
      axios({
        method: 'post',
        url: `${baseurl.URL}/webform_rest/submit?_format=json`,
        headers:{
          'Accept': 'application/vnd.api+json',
          'Content-Type': 'application/json',
          'X-CSRF-Token': token.data,
          'Authorization':'Basic $S$EDSnVMXDICYbVGJ'
        },
        data: {
          "webform_id": "contact_form",
          "name":name,
          "email": email,
          "subject": subject,
          "message": message
        }
      })
    })
    .then(response => {
      console.log(response)
      response.status === 200 && console.log("Form successfully submitted")
    })
    .catch(err => console.log("SUBMIT FAIL ERROR ",err))```

有效。 我已将“访问 Webform 提交资源上的 POST”权限授予匿名用户。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM