简体   繁体   English

提取未在zapier中发布表单数据

[英]fetch not posting form data in zapier

I have a code in zapier: 我在zapier中有一个代码:

var username = "username"
var password = "password"
var grant_type = "password"
var client_id = "id"
var ENDPOINT="someUrl"
var json = {
      "grant_type": grant_type,
      "username": username,
      "password": password,
      "client_id": client_id
};
var options={
  method:"POST",
  headers: {
   'Accept': 'application/json',
   'Content-Type': 'application/json'
  },
  payload:json
}
const result = await fetch(WAVITY_ENDPOINT,options)
const content = await result.json()
output={response:content}

But I am always getting Unauthorized error. 但是我总是收到未经授权的错误。 I do the same through request module and it works. 我通过请求模块做同样的事情,它的工作原理。 I think fetch is not sending the data. 我认为提取未发送数据。 Any help would be appreciated.In my request module code, I have following options: 任何帮助将不胜感激。在我的请求模块代码中,我有以下选择:

headers: {
        connection: "Keep-Alive",
        timeout: 5000
      },
      url: ENDPOINT,
      method: 'POST',
      formData: {
        'grant_type': grant_type,
        'username': username,
        'password': password,
        'client_id': client_id
      }

NOTE: Changing the headers of fetch to headers like in request also does not work for me. 注意:将fetch的标头更改为request中的标头对我也不起作用。

Per this question about fetch , I believe the key for the data should be body , not payload . 对于这个关于提取的问题 ,我相信数据的密钥应该是body ,而不是payload

Zapier uses node-fetch ( source ), so if you can get it working locally with that, you'll be able to paste it into Zapier successfully. Zapier使用node-fetchsource ),因此,如果可以使其在本地使用,则可以成功将其粘贴到Zapier中。

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

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