最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - firebase "long link is not parsable" - Stack Overflow

programmeradmin3浏览0评论

I want to shorten a longLink with firebase and the REST API but I get the following response and I don't know what is wrong:

Response:

   {
        "error": {
            "code": 400,
            "message": "Long link is not parsable:  []",
            "status": "INVALID_ARGUMENT"
        }
    }

And this is how I do it:

The Request: =(hereismyapikey)

the Body lookes like this:

{
   "longDynamicLink": "",
   "suffix": {
    "option": "SHORT"
  }
}

I tried first with the real URL I want to shorten. Same error. Than with google and with and without the http(s). I'm out of options and hope somebody sees what I did wrong here.

EDIT: Full Postman request:

    "item": [
            {
                "name": "shortLinks",
                "request": {
                    "method": "POST",
                    "header": [
                        {
                            "key": "Content-Type",
                            "value": "application/json"
                        }
                    ],
                    "body": {
                        "mode": "raw",
                        "raw": "{\r\n   \"longDynamicLink\": \"www.google.de\",\r\n   \"suffix\": {\r\n    \"option\": \"SHORT\"\r\n  }\r\n}"
                    },
                    "url": {
                        "raw": "",
                        "protocol": "https",
                        "host": [
                            "firebasedynamiclinks",
                            "googleapis",
                            ""
                        ],
                        "path": [
                            "v1",
                            "shortLinks"
                        ],
                        "query": [
                            {
                                "key": "key",
                                "value": "xxx"
                            }
                        ]
                    }
                },
                "response": []
        }
    ]

I want to shorten a longLink with firebase and the REST API but I get the following response and I don't know what is wrong:

Response:

   {
        "error": {
            "code": 400,
            "message": "Long link is not parsable: https://www.google.de [https://firebase.google./docs/dynamic-links/rest#create_a_short_link_from_parameters]",
            "status": "INVALID_ARGUMENT"
        }
    }

And this is how I do it:

The Request: https://firebasedynamiclinks.googleapis./v1/shortLinks?key=(hereismyapikey)

the Body lookes like this:

{
   "longDynamicLink": "https://www.google.de",
   "suffix": {
    "option": "SHORT"
  }
}

I tried first with the real URL I want to shorten. Same error. Than with google and with and without the http(s). I'm out of options and hope somebody sees what I did wrong here.

EDIT: Full Postman request:

    "item": [
            {
                "name": "shortLinks",
                "request": {
                    "method": "POST",
                    "header": [
                        {
                            "key": "Content-Type",
                            "value": "application/json"
                        }
                    ],
                    "body": {
                        "mode": "raw",
                        "raw": "{\r\n   \"longDynamicLink\": \"www.google.de\",\r\n   \"suffix\": {\r\n    \"option\": \"SHORT\"\r\n  }\r\n}"
                    },
                    "url": {
                        "raw": "https://firebasedynamiclinks.googleapis./v1/shortLinks?key=xxx",
                        "protocol": "https",
                        "host": [
                            "firebasedynamiclinks",
                            "googleapis",
                            ""
                        ],
                        "path": [
                            "v1",
                            "shortLinks"
                        ],
                        "query": [
                            {
                                "key": "key",
                                "value": "xxx"
                            }
                        ]
                    }
                },
                "response": []
        }
    ]
Share Improve this question edited Jun 11, 2018 at 13:11 Frank van Puffelen 600k85 gold badges889 silver badges859 bronze badges asked Jun 11, 2018 at 12:16 breezertwobreezertwo 5859 silver badges26 bronze badges 2
  • show you plete request i.e. the curl request or postman request. Hide your api key – Umar Hussain Commented Jun 11, 2018 at 12:20
  • @UmarHussain II added it – breezertwo Commented Jun 11, 2018 at 12:32
Add a ment  | 

3 Answers 3

Reset to default 7

You are using the simple method for creating dynamic link which is roughly equals to the manual creation of dynamic link : https://firebase.google./docs/dynamic-links/create-manually

In the docs if you see the link passed in example carefully you will see the pattern as below:

https://your_subdomain.page.link/?link=your_deep_link&apn=package_name[&amv=minimum_version][&afl=fallback_link]

So you should format the input link according to this or create using the parameters which has very good breakdown of parameters in json:

https://firebase.google./docs/dynamic-links/rest#create_a_short_link_from_parameters

Here is the api reference for firebase dynamic link creation from parameters:

https://firebase.google./docs/reference/dynamic-links/link-shortener#parameters

I find the JSON parameter method is easier.

var body = {
  "dynamicLinkInfo": {
    "dynamicLinkDomain": "yourcustom.page.link",
    "link": fileUrl
  },
  "suffix": {
    "option": "SHORT"
  }
};

Then if you're using Node. The node-fetch package REST call would work like:

  var fetchFileUrl = fetch(YOUR_SHORTLINK_URL, { 
      method: 'POST',
      body: JSON.stringify(body),
      headers: { 'Content-Type': 'application/json' },
  }).then(function(response){
    return response.json();
  });

You need to include the url used by your Firebase dynamic link in the longDynamicLink parameter. If your dynamic link uses the https://myshorter.test url the longDynamicLink bees https://myshorter.test?link= followed by your url.

For example

{
   "longDynamicLink": "https://myshorter.test/?link=https://stackoverflow./",
   "suffix": {
     "option": "SHORT"
   }
}
发布评论

评论列表(0)

  1. 暂无评论