Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Firebase动态链接REST API返回400个错误请求_Javascript_Node.js_Firebase_Firebase Dynamic Links - Fatal编程技术网

Javascript Firebase动态链接REST API返回400个错误请求

Javascript Firebase动态链接REST API返回400个错误请求,javascript,node.js,firebase,firebase-dynamic-links,Javascript,Node.js,Firebase,Firebase Dynamic Links,我正在尝试使用firebase为动态链接提供的RESTAPI在节点中为我的移动应用程序创建动态链接 我遵循了这些原则 我正在使用axios发送我的post请求 这是我的代码: 。。。 常量链接=等待axios({ 方法:“post”, 网址:'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=myApikey', 标题:{ “内容类型”:“应用程序/json”, }, 数据:{ 域名前缀:'https://threadsa

我正在尝试使用firebase为动态链接提供的
RESTAPI
节点中为我的移动应用程序创建动态链接

我遵循了这些原则

我正在使用
axios
发送我的post请求 这是我的代码:

。。。
常量链接=等待axios({
方法:“post”,
网址:'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=myApikey',
标题:{
“内容类型”:“应用程序/json”,
},
数据:{
域名前缀:'https://threadsapp.page.link',
链接:`https://threads-1511.web.app/threads/${tweet.id\u str}`,
iosInfo:{
iosBundleId:'com.bundleId',
iosAppStoreId:'1512677811',
iosIpadBundleId:'com.bundleId',
},
雄激素类:{
androidPackageName:'com.bundleId',
},
socialMetaTagInfo:{
socialTitle:`A thread by${tweet.user.name}`,
社会描述:“${tweet.full_text}”,
社交网站链接:'https://firebasestorage.googleapis.com/v0/b/threads-1511.appspot.com/o/playstore.png?alt=media&token=896f4fe6-2882-442e-b15c-3767d61b8a70',
},
后缀:{
选项:“短”,
},
}
});
...
这是
响应

response: {
    status: 400,
    statusText: 'Bad Request',
    headers: {
      vary: 'X-Origin, Referer, Origin,Accept-Encoding',
      'content-type': 'application/json; charset=UTF-8',
      date: 'Wed, 03 Jun 2020 10:16:24 GMT',
      server: 'ESF',
      'cache-control': 'private',
      'x-xss-protection': '0',
      'x-frame-options': 'SAMEORIGIN',
      'x-content-type-options': 'nosniff',
      'alt-svc': 'h3-27=":443"; ma=2592000,h3-25=":443"; ma=2592000,h3-T050=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q049=":443"; ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"',
      'accept-ranges': 'none',
      connection: 'close',
      'transfer-encoding': 'chunked'
    },
我的所有链接都使用文档中提到的
https://
http://
方案:

至少,提供的深度链接值必须以http://或https://方案开头。它还必须匹配在控制台中输入的任何URL模式白名单。否则,创建API将失败,HTTP错误代码为400


即使我遇到了这个错误,我们也非常感谢您的帮助。

似乎您错过了
的“dynamicLinkInfo”:{
部分,它在数据中应该有点像这样

const link = await axios({
    method: 'post',
    url: 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=myApikey',
    headers: {
      'Content-Type' : 'application/json',
    },
    data: {
        dynamicLinkInfo: {
            domainUriPrefix: 'https://threadsapp.page.link',
            link: `https://threads-1511.web.app/threads/${tweet.id_str}`,
            iosInfo: {
              iosBundleId: 'com.bundleId',
              iosAppStoreId: '1512677811',
              iosIpadBundleId: 'com.bundleId',
            },
            androidInfo: {
              androidPackageName: 'com.bundleId',
            },
            socialMetaTagInfo: {
              socialTitle: `A thread by ${tweet.user.name}`,
              socialDescription: `${tweet.full_text}`,
              socialImageLink: 'https://firebasestorage.googleapis.com/v0/b/threads-1511.appspot.com/o/playstore.png?alt=media&token=896f4fe6-2882-442e-b15c-3767d61b8a70',
            }
        },
        suffix: {
          option: 'SHORT',
        },
    }
  });