Reputation: 842
I am trying to create a dynamic link for my mobile app in node
using the REST API
provided by firebase for dynamic links.
I have followed these instructions
I'm using axios
to send my post request
This is my code:
...
const link = await axios({
method: 'post',
url: 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=myApikey',
headers: {
'Content-Type' : 'application/json',
},
data: {
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',
},
}
});
...
This is the response
:
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'
},
All my links use the https://
or http://
schemes as mentioned in the docs:
At minimum, the deep-link value provided must begin with http:// or https:// schemes. It must also match any URL patterns whitelist entered in the console. Else, the creation API will fail with HTTP error code 400.
Even then I am getting this error, help would be very much appreciated.
Upvotes: 2
Views: 2691
Reputation: 29
seems like you missed the "dynamicLinkInfo": {
part, it should look a bit like this in data
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',
},
}
});
Upvotes: 2